cbfstool: free stale memory

The process probably terminates not much later, but in
case anyone reuses the function in something with
longer life-time, free unused resources.

Change-Id: I10c471ee3d9dc9a3ebf08fe4605f223ea59b990e
Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/6559
Tested-by: build bot (Jenkins)
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Patrick Georgi 2014-08-09 16:58:00 +02:00
parent c5d179123d
commit a65c21eeb5
1 changed files with 4 additions and 1 deletions

View File

@ -281,8 +281,10 @@ phdr_read(const struct buffer *in, struct parsed_elf *pelf,
/* Ensure the contents are valid within the elf file. */ /* Ensure the contents are valid within the elf file. */
if (check_size(in, phdr[i].p_offset, phdr[i].p_filesz, if (check_size(in, phdr[i].p_offset, phdr[i].p_filesz,
"segment contents")) "segment contents")) {
free(phdr);
return -1; return -1;
}
} }
pelf->phdr = phdr; pelf->phdr = phdr;
@ -422,6 +424,7 @@ static int strtab_read(const struct buffer *in, struct parsed_elf *pelf)
buffer_splice(b, in, shdr->sh_offset, shdr->sh_size); buffer_splice(b, in, shdr->sh_offset, shdr->sh_size);
if (check_size(in, shdr->sh_offset, buffer_size(b), "strtab")) { if (check_size(in, shdr->sh_offset, buffer_size(b), "strtab")) {
ERROR("STRTAB section not within bounds: %d\n", i); ERROR("STRTAB section not within bounds: %d\n", i);
free(b);
return -1; return -1;
} }
pelf->strtabs[i] = b; pelf->strtabs[i] = b;