From 0ed18fa177858d67fec42babbca3fef4ae1d939f Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 3 Jun 2020 15:33:01 +0930 Subject: [PATCH] PR26069, strip/objcopy memory leaks PR 26029 * elf.c (_bfd_elf_close_and_cleanup): Free elf_shstrtab for core files as well as objects. --- bfd/ChangeLog | 6 ++++++ bfd/elf.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index a3e777e990..21302711f4 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2020-06-03 Alan Modra + + PR 26029 + * elf.c (_bfd_elf_close_and_cleanup): Free elf_shstrtab for + core files as well as objects. + 2020-06-01 H.J. Lu PR ld/26067 diff --git a/bfd/elf.c b/bfd/elf.c index e335ff7efb..9ca42e10d8 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)); -- 2.34.1