diff options
author | Alan Modra <amodra@gmail.com> | 2020-08-05 17:38:26 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-08-05 17:40:02 +0930 |
commit | 787bbc56d895b452ebfe90bc2b1345ca825fa412 (patch) | |
tree | 7952b5be6fa8db4201d21ef6c2cd0742f06ebeac | |
parent | 0b97e818464a42305c8243a980a5c13967554fd9 (diff) | |
download | gdb-787bbc56d895b452ebfe90bc2b1345ca825fa412.zip gdb-787bbc56d895b452ebfe90bc2b1345ca825fa412.tar.gz gdb-787bbc56d895b452ebfe90bc2b1345ca825fa412.tar.bz2 |
Revert "PR26337, Malloc size error in objdump"
This reverts commit 0b97e818464a42305c8243a980a5c13967554fd9.
-rw-r--r-- | binutils/ChangeLog | 5 | ||||
-rw-r--r-- | binutils/objdump.c | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index a924ae2..0aab6a2 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,6 +1,11 @@ 2020-08-05 Alan Modra <amodra@gmail.com> PR 26337 + * objdump.c (load_specific_debug_section): Revert last change. + +2020-08-05 Alan Modra <amodra@gmail.com> + + PR 26337 * objdump.c (load_specific_debug_section): Don't malloc space for section contents, use bfd_malloc_and_get_section. diff --git a/binutils/objdump.c b/binutils/objdump.c index 1b48cd3..79ef051 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -3545,7 +3545,6 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, if (streq (section->filename, bfd_get_filename (abfd))) return TRUE; free (section->start); - section->start = NULL; } section->filename = bfd_get_filename (abfd); @@ -3558,20 +3557,22 @@ load_specific_debug_section (enum dwarf_section_display_enum debug, alloced = amt = section->size + 1; if (alloced != amt || alloced == 0) { + section->start = NULL; free_debug_section (debug); printf (_("\nSection '%s' has an invalid size: %#llx.\n"), sanitize_string (section->name), (unsigned long long) section->size); return FALSE; } - if (!bfd_malloc_and_get_section (abfd, sec, &contents)) + section->start = contents = malloc (alloced); + if (section->start == NULL + || !bfd_get_full_section_contents (abfd, sec, &contents)) { free_debug_section (debug); printf (_("\nCan't get contents for section '%s'.\n"), sanitize_string (section->name)); return FALSE; } - section->start = contents; /* Ensure any string section has a terminating NUL. */ section->start[section->size] = 0; |