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.
This commit is contained in:
Alan Modra 2025-01-11 15:50:20 +10:30
parent 701fe09b04
commit 525e2ebb89

View file

@ -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;