aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-12-07 23:39:42 +1030
committerAlan Modra <amodra@gmail.com>2018-12-08 00:11:16 +1030
commitc2f5dc30afa34696f2da0081c4ac50b958ecb0e9 (patch)
tree2dd48a0c34c7f6284e565185c0165ddffd3a86d6 /bfd
parentaf03af8f55f2536b6e20928e6b1fa0324a5f3d6e (diff)
downloadgdb-c2f5dc30afa34696f2da0081c4ac50b958ecb0e9.zip
gdb-c2f5dc30afa34696f2da0081c4ac50b958ecb0e9.tar.gz
gdb-c2f5dc30afa34696f2da0081c4ac50b958ecb0e9.tar.bz2
PR23952, memory leak in _bfd_generic_read_minisymbols
bfd/ PR 23952 * syms.c (_bfd_generic_read_minisymbols): Free syms before returning with zero symcount. binutils/ * nm.c (display_rel_file): Use xrealloc to increase minisyms for synthetic symbols.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/syms.c13
2 files changed, 16 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8a37271..b7d6717 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2018-12-07 Alan Modra <amodra@gmail.com>
+
+ PR 23952
+ * syms.c (_bfd_generic_read_minisymbols): Free syms before
+ returning with zero symcount.
+
2018-12-06 Alan Modra <amodra@gmail.com>
* elf32-ppc.c (ppc_elf_howto_raw <R_PPC_VLE_ADDR20>): Correct
diff --git a/bfd/syms.c b/bfd/syms.c
index e09640a..cbf85cb 100644
--- a/bfd/syms.c
+++ b/bfd/syms.c
@@ -822,9 +822,16 @@ _bfd_generic_read_minisymbols (bfd *abfd,
if (symcount < 0)
goto error_return;
- *minisymsp = syms;
- *sizep = sizeof (asymbol *);
-
+ if (symcount == 0)
+ /* We return 0 above when storage is 0. Exit in the same state
+ here, so as to not complicate callers with having to deal with
+ freeing memory for zero symcount. */
+ free (syms);
+ else
+ {
+ *minisymsp = syms;
+ *sizep = sizeof (asymbol *);
+ }
return symcount;
error_return: