]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
objdump sym memory leak
authorAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:22:51 +0000 (22:52 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 1 Jan 2025 12:22:51 +0000 (22:52 +1030)
The sym array should be freed even with a symcount of zero.

* objdump.c (dump_bfd): Free syms before replacing with
extra_syms.  Free extra_syms after adding to syms.

binutils/objdump.c

index 478086a42c5ea21b3901d6919ab4bb4ca4f117dc..ecbe39e942e32ad34402096e886f15e6c2c3ba65 100644 (file)
@@ -5730,6 +5730,7 @@ dump_bfd (bfd *abfd, bool is_mainfile)
                {
                  if (old_symcount == 0)
                    {
+                     free (syms);
                      syms = extra_syms;
                    }
                  else
@@ -5739,6 +5740,7 @@ dump_bfd (bfd *abfd, bool is_mainfile)
                      memcpy (syms + old_symcount,
                              extra_syms,
                              (symcount + 1) * sizeof (asymbol *));
+                     free (extra_syms);
                    }
                }