libelf: Fix possible resource leak in elf[32|64]_updatefile.

When we cannot allocate enough memory to convert the data in
updatemmap we should free the scns before returning an error.

Signed-off-by: Mark Wielaard <mark@klomp.org>
This commit is contained in:
Mark Wielaard
2019-03-06 19:56:54 +01:00
parent 142a51944d
commit 75e147d0ab
2 changed files with 6 additions and 0 deletions
+5
View File
@@ -1,3 +1,8 @@
2019-03-06 Mark Wielaard <mark@klomp.org>
* elf32_updatefile.c (updatemmap): Free scns before returning
allocation failure.
2019-02-24 Mark Wielaard <mark@klomp.org>
* gelf_xlate.c (__elf_xfctstof): Remove alias.
+1
View File
@@ -365,6 +365,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
char *converted = aligned_alloc (align, size);
if (converted == NULL)
{
free (scns);
__libelf_seterrno (ELF_E_NOMEM);
return 1;
}