From e5ef2728bd44c528fe8800b0b0326ab69589229d Mon Sep 17 00:00:00 2001 From: Arjun Moudgil Date: Tue, 15 Sep 2020 20:46:35 -0400 Subject: [PATCH] Added check for if info.dli_sname is NULL Check if info.dli_sname is NULL, If the image containing addr is found, but no nearest symbol was found, the dli_sname and dli_saddr fields are set to NULL. --- src/symbolize.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/symbolize.cc b/src/symbolize.cc index 76a1b0f..7767c90 100644 --- a/src/symbolize.cc +++ b/src/symbolize.cc @@ -857,11 +857,13 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out, int out_size) { Dl_info info; if (dladdr(pc, &info)) { - if ((int)strlen(info.dli_sname) < out_size) { - strcpy(out, info.dli_sname); - // Symbolization succeeded. Now we try to demangle the symbol. - DemangleInplace(out, out_size); - return true; + if (info.dli_sname) { + if ((int)strlen(info.dli_sname) < out_size) { + strcpy(out, info.dli_sname); + // Symbolization succeeded. Now we try to demangle the symbol. + DemangleInplace(out, out_size); + return true; + } } } return false;