Merge pull request #579 from arj-fb/safety_check_at_SymbolizeAndDemangle

Added check for if info.dli_sname is NULL
This commit is contained in:
Sergiu Deitsch 2020-09-29 22:10:08 +02:00 committed by GitHub
commit d442460690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -857,6 +857,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
int out_size) { int out_size) {
Dl_info info; Dl_info info;
if (dladdr(pc, &info)) { if (dladdr(pc, &info)) {
if (info.dli_sname) {
if ((int)strlen(info.dli_sname) < out_size) { if ((int)strlen(info.dli_sname) < out_size) {
strcpy(out, info.dli_sname); strcpy(out, info.dli_sname);
// Symbolization succeeded. Now we try to demangle the symbol. // Symbolization succeeded. Now we try to demangle the symbol.
@ -864,6 +865,7 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
return true; return true;
} }
} }
}
return false; return false;
} }