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 43816ebc33. Without this check, GDB
aborts when loading symbols from some binaries.

gdb/ChangeLog
2020-02-21  Ali Tamur  <tamur@google.com>

	* dwarf2/read.c (dwarf2_name): Add null check.
This commit is contained in:
Ali Tamur via gdb-patches 2020-02-21 08:19:21 -07:00 committed by Tom Tromey
parent a4425a57c7
commit 4f180d5396
2 changed files with 6 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2020-02-21 Ali Tamur <tamur@google.com>
* dwarf2/read.c (dwarf2_name): Add null check.
2020-02-20 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (dwarf2_find_containing_comp_unit): Use ">", not

View File

@ -21756,6 +21756,8 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
{
gdb::unique_xmalloc_ptr<char> demangled
(gdb_demangle (DW_STRING (attr), DMGL_TYPES));
if (demangled == nullptr)
return nullptr;
const char *base;