[binutils-gdb] objdump sym memory leak
Alan Modra
amodra@sourceware.org
Wed Jan 1 12:46:41 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0e4e9aa0a7727819a0b5b240617f8f4243c4c80f
commit 0e4e9aa0a7727819a0b5b240617f8f4243c4c80f
Author: Alan Modra <amodra@gmail.com>
Date: Wed Jan 1 22:52:51 2025 +1030
objdump sym memory leak
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.
Diff:
---
binutils/objdump.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/binutils/objdump.c b/binutils/objdump.c
index 478086a42c5..ecbe39e942e 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -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);
}
}
More information about the Binutils-cvs
mailing list