summaryrefslogtreecommitdiffstats
path: root/libelf/elf32_updatefile.c
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2016-02-13 19:51:48 +0100
committerMark Wielaard <[email protected]>2016-02-22 12:14:44 +0100
commit7249c8e4b5ad7b5dfea0d8bf2a9ca05469575822 (patch)
tree48214f72479b0f40b00e6cef7f4c62620f74af87 /libelf/elf32_updatefile.c
parentee38add05d201eb79a36c89b92dddedbc909a1c7 (diff)
libelf: Don't leak memory when out of memory in updatemmap.
We forgot to free scns when returning ELF_E_NOMEM. Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'libelf/elf32_updatefile.c')
-rw-r--r--libelf/elf32_updatefile.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 09092197..d0fabb16 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -1,5 +1,5 @@
/* Write changed data structures.
- Copyright (C) 2000-2010, 2014, 2015 Red Hat, Inc.
+ Copyright (C) 2000-2010, 2014, 2015, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <[email protected]>, 2000.
@@ -269,6 +269,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
void *p = malloc (sizeof (ElfW2(LIBELFBITS,Shdr)));
if (unlikely (p == NULL))
{
+ free (scns);
__libelf_seterrno (ELF_E_NOMEM);
return -1;
}
@@ -295,6 +296,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
void *p = malloc (scn->data_list.data.d.d_size);
if (unlikely (p == NULL))
{
+ free (scns);
__libelf_seterrno (ELF_E_NOMEM);
return -1;
}