Check for null result from gdb_demangle
authorAli Tamur via gdb-patches <gdb-patches@sourceware.org>
Fri, 21 Feb 2020 15:19:21 +0000 (08:19 -0700)
committerTom Tromey <tromey@adacore.com>
Fri, 21 Feb 2020 15:19:21 +0000 (08:19 -0700)
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  <tamur@google.com>

* dwarf2/read.c (dwarf2_name): Add null check.

gdb/ChangeLog
gdb/dwarf2/read.c

index 748788acac15e2d822f0c236a8567c6126894356..d480ff4e1596819084c4fcec3b93648c1c1990bf 100644 (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
index f998fe6b8d0ba383deb3340ba374b9664ea82b3a..46d510eb274c52759ce8a9037d57a9ddf95438b4 100644 (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;
 
This page took 0.03452 seconds and 4 git commands to generate.