aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-06-14 13:46:56 +0930
committerAlan Modra <amodra@gmail.com>2023-06-14 14:24:33 +0930
commit48375c36dc59e3c0e6b9bf38f17f4692bddb578f (patch)
tree3a9603a7011dcc9d20c48599dca9b922eba40113 /bfd
parent3bedac2939328dc74e9bfa36a26201ec0d9e0b61 (diff)
downloadgdb-48375c36dc59e3c0e6b9bf38f17f4692bddb578f.zip
gdb-48375c36dc59e3c0e6b9bf38f17f4692bddb578f.tar.gz
gdb-48375c36dc59e3c0e6b9bf38f17f4692bddb578f.tar.bz2
Re: bfd/elf.c strtab memory leak
There are other places that leak the strtab. * elf.c (_bfd_elf_compute_section_file_positions): Free strtab on error paths.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/elf.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index c4e2f89..8f6d7d1 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -4254,11 +4254,7 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
{
bfd_map_over_sections (abfd, bfd_elf_set_group_contents, &failed);
if (failed)
- {
- if (need_symtab)
- _bfd_elf_strtab_free (strtab);
- return false;
- }
+ goto err_free_strtab;
}
shstrtab_hdr = &elf_tdata (abfd)->shstrtab_hdr;
@@ -4274,9 +4270,9 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
shstrtab_hdr->sh_addralign = 1;
if (!assign_file_positions_except_relocs (abfd, link_info))
- return false;
+ goto err_free_strtab;
- if (need_symtab)
+ if (strtab != NULL)
{
file_ptr off;
Elf_Internal_Shdr *hdr;
@@ -4303,13 +4299,17 @@ _bfd_elf_compute_section_file_positions (bfd *abfd,
out. */
if (bfd_seek (abfd, hdr->sh_offset, SEEK_SET) != 0
|| ! _bfd_elf_strtab_emit (abfd, strtab))
- return false;
+ goto err_free_strtab;
_bfd_elf_strtab_free (strtab);
}
abfd->output_has_begun = true;
-
return true;
+
+ err_free_strtab:
+ if (strtab != NULL)
+ _bfd_elf_strtab_free (strtab);
+ return false;
}
/* Retrieve .eh_frame_hdr. Prior to size_dynamic_sections the