]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
memory leak in objdump disassemble_section
authorAlan Modra <amodra@gmail.com>
Wed, 7 Feb 2024 01:28:10 +0000 (11:58 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 7 Feb 2024 10:58:24 +0000 (21:28 +1030)
* objdump.c (disassemble_section): Free rel_ppstart on error path.

binutils/objdump.c

index 49e944b1dfd7bd839223c149196bdac74ad4f0e9..7beb221cb2f1101a32022d24114eca4a3908de4a 100644 (file)
@@ -3795,6 +3795,7 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
     {
       non_fatal (_("Reading section %s failed because: %s"),
                 section->name, bfd_errmsg (bfd_get_error ()));
+      free (rel_ppstart);
       return;
     }
 
@@ -4075,9 +4076,7 @@ disassemble_section (bfd *abfd, asection *section, void *inf)
     }
 
   free (data);
-
-  if (rel_ppstart != NULL)
-    free (rel_ppstart);
+  free (rel_ppstart);
 }
 
 /* Disassemble the contents of an object file.  */