diff options
author | Alan Modra <amodra@gmail.com> | 2025-01-04 13:39:20 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2025-01-04 19:15:56 +1030 |
commit | 003ced705f6d4c10b7f0fb96acf7ec2db58f902e (patch) | |
tree | af8b13a906b8bdb588e211fe6ff303f049f87c1d /bfd | |
parent | c232d080c4f05b16e998bd49d6e2d92c56b6421e (diff) | |
download | binutils-003ced705f6d4c10b7f0fb96acf7ec2db58f902e.zip binutils-003ced705f6d4c10b7f0fb96acf7ec2db58f902e.tar.gz binutils-003ced705f6d4c10b7f0fb96acf7ec2db58f902e.tar.bz2 |
ELF sec_info memory leaks
Use the bfd's objalloc memory so we don't need to free anything
attached to elf_section_data sec_info. Other uses of sec_info that
need to allocate memory already use bfd_alloc.
* elf-eh-frame.c (_bfd_elf_parse_eh_frame): bfd_alloc sec_info.
* elf-sframe.c (_bfd_elf_parse_sframe): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elf-eh-frame.c | 7 | ||||
-rw-r--r-- | bfd/elf-sframe.c | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c index 9a43f1f..d903e27 100644 --- a/bfd/elf-eh-frame.c +++ b/bfd/elf-eh-frame.c @@ -655,9 +655,9 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info, REQUIRE (skip_bytes (&buf, end, hdr_length - 4)); } - sec_info = (struct eh_frame_sec_info *) - bfd_zmalloc (sizeof (struct eh_frame_sec_info) - + (num_entries - 1) * sizeof (struct eh_cie_fde)); + sec_info = bfd_zalloc (abfd, + (sizeof (struct eh_frame_sec_info) + + (num_entries - 1) * sizeof (struct eh_cie_fde))); REQUIRE (sec_info); /* We need to have a "struct cie" for each CIE in this section. */ @@ -1050,7 +1050,6 @@ _bfd_elf_parse_eh_frame (bfd *abfd, struct bfd_link_info *info, (_("error in %pB(%pA); no .eh_frame_hdr table will be created"), abfd, sec); hdr_info->u.dwarf.table = false; - free (sec_info); success: _bfd_elf_munmap_section_contents (sec, ehbuf); free (local_cies); diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c index 874d7c2..abc5c52 100644 --- a/bfd/elf-sframe.c +++ b/bfd/elf-sframe.c @@ -214,7 +214,7 @@ _bfd_elf_parse_sframe (bfd *abfd, /* Decode the buffer and keep decoded contents for later use. Relocations are performed later, but are such that the section's size is unaffected. */ - sfd_info = bfd_malloc (sizeof (struct sframe_dec_info)); + sfd_info = bfd_alloc (abfd, sizeof (*sfd_info)); sf_size = sec->size; sfd_info->sfd_ctx = sframe_decode ((const char*)sfbuf, sf_size, &decerr); |