diff options
author | Alan Modra <amodra@gmail.com> | 2018-12-07 23:39:42 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2018-12-08 00:11:16 +1030 |
commit | c2f5dc30afa34696f2da0081c4ac50b958ecb0e9 (patch) | |
tree | 2dd48a0c34c7f6284e565185c0165ddffd3a86d6 /binutils/nm.c | |
parent | af03af8f55f2536b6e20928e6b1fa0324a5f3d6e (diff) | |
download | fsf-binutils-gdb-c2f5dc30afa34696f2da0081c4ac50b958ecb0e9.zip fsf-binutils-gdb-c2f5dc30afa34696f2da0081c4ac50b958ecb0e9.tar.gz fsf-binutils-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 'binutils/nm.c')
-rw-r--r-- | binutils/nm.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/binutils/nm.c b/binutils/nm.c index 8807832..39083c3 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -1175,17 +1175,14 @@ display_rel_file (bfd *abfd, bfd *archive_bfd) if (synth_count > 0) { asymbol **symp; - void *new_mini; long i; - new_mini = xmalloc ((symcount + synth_count + 1) * sizeof (*symp)); - symp = (asymbol **) new_mini; - memcpy (symp, minisyms, symcount * sizeof (*symp)); - symp += symcount; + minisyms = xrealloc (minisyms, + (symcount + synth_count + 1) * sizeof (*symp)); + symp = (asymbol **) minisyms + symcount; for (i = 0; i < synth_count; i++) *symp++ = synthsyms + i; *symp = 0; - minisyms = new_mini; symcount += synth_count; } } |