nm: Handle dwarf_linesrc returning NULL.
authorMark Wielaard <mjw@redhat.com>
Wed, 6 May 2015 10:45:49 +0000 (12:45 +0200)
committerMark Wielaard <mjw@redhat.com>
Tue, 12 May 2015 14:41:05 +0000 (16:41 +0200)
https://bugzilla.redhat.com/show_bug.cgi?id=1170810#32

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/nm.c

index a7cdc3e..7a44fc6 100644 (file)
@@ -1,3 +1,7 @@
+2015-05-05  Mark Wielaard  <mjw@redhat.com>
+
+       * nm.c (show_symbols): Handle dwarf_linesrc returning NULL.
+
 2015-05-04  Max Filippov  <jcmvbkbc@gmail.com>
 
        * ar.c (do_oper_extract): Replace struct timeval with struct timespec
index b6a1e6e..7d20bbb 100644 (file)
--- a/src/nm.c
+++ b/src/nm.c
@@ -1297,11 +1297,10 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn,
                          /* We found the line.  */
                          int lineno;
                          (void) dwarf_lineno (line, &lineno);
+                         const char *file = dwarf_linesrc (line, NULL, NULL);
+                         file = (file != NULL) ? basename (file) : "???";
                          int n;
-                         n = obstack_printf (&whereob, "%s:%d%c",
-                                             basename (dwarf_linesrc (line,
-                                                                      NULL,
-                                                                      NULL)),
+                         n = obstack_printf (&whereob, "%s:%d%c", file,
                                              lineno, '\0');
                          sym_mem[nentries_used].where
                            = obstack_finish (&whereob);