PR22232, NULL pointer dereference in load_specific_debug_section
authorAlan Modra <amodra@gmail.com>
Sun, 1 Oct 2017 11:10:23 +0000 (21:40 +1030)
committerAlan Modra <amodra@gmail.com>
Sun, 1 Oct 2017 11:11:16 +0000 (21:41 +1030)
PR 22232
PR 22230
* objdump.c (load_specific_debug_section): Introduce a temp to
stop bfd_get_full_section_contents NULLing out section->start.

binutils/ChangeLog
binutils/objdump.c

index d45eeaf9b5ad72ea2717521359a7b472d67ca83f..95cf50ba405890bca1491cdf9ff99037134f64cb 100644 (file)
@@ -1,3 +1,10 @@
+2017-10-01  Alan Modra  <amodra@gmail.com>
+
+       PR 22232
+       PR 22230
+       * objdump.c (load_specific_debug_section): Introduce a temp to
+       stop bfd_get_full_section_contents NULLing out section->start.
+
 2017-10-01  Alan Modra  <amodra@gmail.com>
 
        PR 22230
index 83b8b2a273b3998fa64f95b41c39827d86fe80b7..98c316aae582a8fc2ea1b5a364917aa425fd745b 100644 (file)
@@ -2465,6 +2465,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
 {
   struct dwarf_section *section = &debug_displays [debug].section;
   bfd *abfd = (bfd *) file;
+  bfd_byte *contents;
   bfd_boolean ret;
 
   /* If it is already loaded, do nothing.  */
@@ -2475,10 +2476,10 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
   section->num_relocs = 0;
   section->address = bfd_get_section_vma (abfd, sec);
   section->size = bfd_get_section_size (sec);
-  section->start = malloc (section->size + 1);
+  section->start = contents = malloc (section->size + 1);
   section->user_data = sec;
   if (section->start == NULL
-      || !bfd_get_full_section_contents (abfd, sec, &section->start))
+      || !bfd_get_full_section_contents (abfd, sec, &contents))
     {
       free_debug_section (debug);
       printf (_("\nCan't get contents for section '%s'.\n"),
This page took 0.036875 seconds and 4 git commands to generate.