]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
objdump: sframe: fix memory leaks
authorIndu Bhagat <indu.bhagat@oracle.com>
Fri, 9 Dec 2022 18:25:46 +0000 (10:25 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 9 Dec 2022 18:25:46 +0000 (10:25 -0800)
ChangeLog:

* binutils/objdump.c (dump_section_sframe): free up contents and
SFrame decoder context on exit.

binutils/objdump.c

index d95c8b68bf06f0c60b6332789b676db439023781..6695c5d343f45dfa6229485bbabc8dddf89ef91c 100644 (file)
@@ -4871,12 +4871,18 @@ dump_section_sframe (bfd *abfd ATTRIBUTE_UNUSED,
   /* Decode the contents of the section.  */
   sfd_ctx = sframe_decode ((const char*)sframe_data, sf_size, &err);
   if (!sfd_ctx)
-    bfd_fatal (bfd_get_filename (abfd));
+    {
+      free (sframe_data);
+      bfd_fatal (bfd_get_filename (abfd));
+    }
 
   printf (_("Contents of the SFrame section %s:"),
          sanitize_string (sect_name));
   /* Dump the contents as text.  */
   dump_sframe (sfd_ctx, sf_vma);
+
+  free (sframe_data);
+  sframe_decoder_free (&sfd_ctx);
 }
 
 \f