diff options
| author | Mark Wielaard <[email protected]> | 2014-12-16 22:19:08 +0100 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2014-12-17 16:49:03 +0100 |
| commit | 322709393b5881f4fc2fe1a03a00434edd8a5ce4 (patch) | |
| tree | 2ae9b4bb2cd8c4f6687c17974666bd796f0310cd /src/readelf.c | |
| parent | 55f847d63ae3ef7d4469628070d2adb74004c584 (diff) | |
readelf: Print dwarf_errmsg if dwarf_onesrcline or dwarf_linesrc fails.
Don't just crash using the NULL result in print_decoded_line_section.
Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src/readelf.c')
| -rw-r--r-- | src/readelf.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/readelf.c b/src/readelf.c index 9c62853e..08b3ae47 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -6256,9 +6256,19 @@ print_decoded_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, for (size_t n = 0; n < nlines; n++) { Dwarf_Line *line = dwarf_onesrcline (lines, n); + if (line == NULL) + { + printf (" dwarf_onesrcline: %s\n", dwarf_errmsg (-1)); + continue; + } Dwarf_Word mtime, length; const char *file = dwarf_linesrc (line, &mtime, &length); - if (strcmp (last_file, file) != 0) + if (file == NULL) + { + printf (" <%s> (mtime: ?, length: ?)\n", dwarf_errmsg (-1)); + last_file = ""; + } + else if (strcmp (last_file, file) != 0) { printf (" %s (mtime: %" PRIu64 ", length: %" PRIu64 ")\n", file, mtime, length); |
