diff options
author | Mark Wielaard <mark@klomp.org> | 2019-03-06 19:56:54 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2019-03-06 19:56:54 +0100 |
commit | 75e147d0ab85262d9bb2fff093db7ce67dbd4b62 (patch) | |
tree | ed99c34b782365030e576497108a204197b812fa | |
parent | 142a51944db63f64d4839c65e904df48474dcb12 (diff) | |
download | elfutils-75e147d0ab85262d9bb2fff093db7ce67dbd4b62.tar.gz |
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>
-rw-r--r-- | libelf/ChangeLog | 5 | ||||
-rw-r--r-- | libelf/elf32_updatefile.c | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index a2e4ee90..fd908e28 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -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. diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index 2899c6fb..457d18e6 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -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; } |