aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-06-03 15:33:01 +0930
committerAlan Modra <amodra@gmail.com>2020-06-03 17:59:44 +0930
commit0ed18fa177858d67fec42babbca3fef4ae1d939f (patch)
tree8b13433c420c91db60bfc1d0607a2a5337cbfc5a /bfd/elf.c
parentbb7322c67111024f5977deb85abd777ec713b1a9 (diff)
downloadgdb-0ed18fa177858d67fec42babbca3fef4ae1d939f.zip
gdb-0ed18fa177858d67fec42babbca3fef4ae1d939f.tar.gz
gdb-0ed18fa177858d67fec42babbca3fef4ae1d939f.tar.bz2
PR26069, strip/objcopy memory leaks
PR 26029 * elf.c (_bfd_elf_close_and_cleanup): Free elf_shstrtab for core files as well as objects.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index e335ff7..9ca42e1 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -9438,7 +9438,9 @@ bfd_boolean
_bfd_elf_close_and_cleanup (bfd *abfd)
{
struct elf_obj_tdata *tdata = elf_tdata (abfd);
- if (bfd_get_format (abfd) == bfd_object && tdata != NULL)
+ if (tdata != NULL
+ && (bfd_get_format (abfd) == bfd_object
+ || bfd_get_format (abfd) == bfd_core))
{
if (elf_tdata (abfd)->o != NULL && elf_shstrtab (abfd) != NULL)
_bfd_elf_strtab_free (elf_shstrtab (abfd));