[binutils-gdb] sframe memory leak
Alan Modra
amodra@sourceware.org
Wed Jan 15 12:08:12 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=525e2ebb8946de9aa630910efa8bb633eceea2d7
commit 525e2ebb8946de9aa630910efa8bb633eceea2d7
Author: Alan Modra <amodra@gmail.com>
Date: Sat Jan 11 15:50:20 2025 +1030
sframe memory leak
This is another case where an array isn't freed anywhere and needs to
persist a while, so allocate it with bfd_alloc.
* elf-sframe.c (sframe_decoder_init_func_bfdinfo): Add abfd
param. bfd_zalloc std_func_bfdinfo.
(_bfd_elf_parse_sframe): Adjust to suit.
Diff:
---
bfd/elf-sframe.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index abc5c525f6f..67ed874e025 100644
--- a/bfd/elf-sframe.c
+++ b/bfd/elf-sframe.c
@@ -97,7 +97,8 @@ sframe_decoder_set_func_reloc_index (struct sframe_dec_info *sfd_info,
needed for linking SEC. Returns TRUE if setup is done successfully. */
static bool
-sframe_decoder_init_func_bfdinfo (asection *sec,
+sframe_decoder_init_func_bfdinfo (bfd *abfd,
+ asection *sec,
struct sframe_dec_info *sfd_info,
struct elf_reloc_cookie *cookie)
{
@@ -109,11 +110,9 @@ sframe_decoder_init_func_bfdinfo (asection *sec,
/* Allocate and clear the memory. */
func_bfdinfo_size = (sizeof (struct sframe_func_bfdinfo)) * fde_count;
- sfd_info->sfd_func_bfdinfo
- = (struct sframe_func_bfdinfo*) bfd_malloc (func_bfdinfo_size);
+ sfd_info->sfd_func_bfdinfo = bfd_zalloc (abfd, func_bfdinfo_size);
if (sfd_info->sfd_func_bfdinfo == NULL)
return false;
- memset (sfd_info->sfd_func_bfdinfo, 0, func_bfdinfo_size);
/* For linker generated .sframe sections, we have no relocs. Skip. */
if ((sec->flags & SEC_LINKER_CREATED) && cookie->rels == NULL)
@@ -224,7 +223,7 @@ _bfd_elf_parse_sframe (bfd *abfd,
sframe_decode in case of error. */
goto fail_no_free;
- if (!sframe_decoder_init_func_bfdinfo (sec, sfd_info, cookie))
+ if (!sframe_decoder_init_func_bfdinfo (abfd, sec, sfd_info, cookie))
{
sframe_decoder_free (&sfd_ctx);
goto fail_no_free;
More information about the Binutils-cvs
mailing list