tests: Handle dwarf_attr_string returning NULL in show-die-info.c
authorMark Wielaard <mark@klomp.org>
Wed, 6 Oct 2021 21:53:34 +0000 (23:53 +0200)
committerMark Wielaard <mark@klomp.org>
Wed, 6 Oct 2021 21:53:34 +0000 (23:53 +0200)
Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Signed-off-by: Mark Wielaard <mark@klomp.org>
tests/ChangeLog
tests/show-die-info.c

index d289b27..07e018b 100644 (file)
@@ -1,3 +1,7 @@
+2021-10-06  Mark Wielaard  <mark@klomp.org>
+
+       * show-die-info.c (handle): Handle dwarf_attr_string returning NULL.
+
 2021-10-06  Di Chen <dichen@redhat.com>
 
        PR28242
index 34e27a3..1a3191c 100644 (file)
@@ -97,7 +97,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n)
   printf ("%*s Attrs     :", n * 5, "");
   for (cnt = 0; cnt < 0xffff; ++cnt)
     if (dwarf_hasattr (die, cnt))
-      printf (" %s", dwarf_attr_string (cnt));
+      printf (" %s", dwarf_attr_string (cnt) ?: "<unknown>");
   puts ("");
 
   if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0)