Hi Mark, LGTM.
Aaron On Sun, Nov 8, 2026 at 6:50 PM Mark Wielaard <[email protected]> wrote: > > Make sure ar_sym is always freed and set to NULL on error. > > * libelf/elf_getarsym.c (elf_getarsym): Free ar_sym on > temp_data malloc failures. > > Signed-off-by: Mark Wielaard <[email protected]> > --- > libelf/elf_getarsym.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c > index 2ba867ec9826..92af9645338a 100644 > --- a/libelf/elf_getarsym.c > +++ b/libelf/elf_getarsym.c > @@ -212,6 +212,8 @@ elf_getarsym (Elf *elf, size_t *ptr) > temp_data = malloc (sz); > if (unlikely (temp_data == NULL)) > { > + free (elf->state.ar.ar_sym); > + elf->state.ar.ar_sym = NULL; > __libelf_seterrno (ELF_E_NOMEM); > goto out; > } > @@ -255,6 +257,8 @@ elf_getarsym (Elf *elf, size_t *ptr) > temp_data = malloc (sz); > if (unlikely (temp_data == NULL)) > { > + free (elf->state.ar.ar_sym); > + elf->state.ar.ar_sym = NULL; > __libelf_seterrno (ELF_E_NOMEM); > goto out; > } > -- > 2.56.0 >
