From: Ali Tamur via gdb-patches Date: Fri, 21 Feb 2020 15:19:21 +0000 (-0700) Subject: Check for null result from gdb_demangle X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4f180d5396741eb65badba70cf5077b7d48f8641;p=binutils-gdb.git Check for null result from gdb_demangle I am sending this patch on behalf of kmoy@google.com, who discovered the bug and wrote the fix. gdb_demangle can return null for strings that don't properly demangle. The null check was mistakenly removed in commit 43816ebc335. Without this check, GDB aborts when loading symbols from some binaries. gdb/ChangeLog 2020-02-21 Ali Tamur * dwarf2/read.c (dwarf2_name): Add null check. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 748788acac1..d480ff4e159 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2020-02-21 Ali Tamur + + * dwarf2/read.c (dwarf2_name): Add null check. + 2020-02-20 Tom Tromey * dwarf2/read.c (dwarf2_find_containing_comp_unit): Use ">", not diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f998fe6b8d0..46d510eb274 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -21756,6 +21756,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu) { gdb::unique_xmalloc_ptr demangled (gdb_demangle (DW_STRING (attr), DMGL_TYPES)); + if (demangled == nullptr) + return nullptr; const char *base;