[2/4] libelf: elf32_getshdr might leak section header when out of memory
Commit Message
Found by GCC -fanalyzer.
When allocating the notcvt buffer fails we leak the shdr. goto
free_and_out on malloc failure.
* libelf/elf32_getshdr.c (load_shdr_wrlock): goto
free_and_out on second malloc failure.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/elf32_getshdr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -126,7 +126,7 @@ load_shdr_wrlock (Elf_Scn *scn)
if (unlikely (notcvt == NULL))
{
__libelf_seterrno (ELF_E_NOMEM);
- goto out;
+ goto free_and_out;
}
memcpy (notcvt, ((char *) elf->map_address
+ elf->start_offset + ehdr->e_shoff),