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 <m...@klomp.org> --- libelf/elf32_getshdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c index fc696302b8b6..19b690a8e87b 100644 --- a/libelf/elf32_getshdr.c +++ b/libelf/elf32_getshdr.c @@ -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), -- 2.45.2