diff options
author | Patrick Georgi <patrick@georgi-clan.de> | 2014-08-09 16:58:00 +0200 |
---|---|---|
committer | Patrick Georgi <patrick@georgi-clan.de> | 2014-08-10 08:20:30 +0200 |
commit | a65c21eeb52103698555996eb541eae34a6c2adb (patch) | |
tree | 8200025cb2fdb0de01f64774d02c23101dc4363c /util/cbfstool/elfheaders.c | |
parent | c5d179123df5e7d8b72e613935b9e1bd278886f9 (diff) | |
download | coreboot-a65c21eeb52103698555996eb541eae34a6c2adb.tar.xz |
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>
Diffstat (limited to 'util/cbfstool/elfheaders.c')
-rw-r--r-- | util/cbfstool/elfheaders.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c index 5b5cf94276..71d34a9df5 100644 --- a/util/cbfstool/elfheaders.c +++ b/util/cbfstool/elfheaders.c @@ -281,8 +281,10 @@ phdr_read(const struct buffer *in, struct parsed_elf *pelf, /* Ensure the contents are valid within the elf file. */ if (check_size(in, phdr[i].p_offset, phdr[i].p_filesz, - "segment contents")) + "segment contents")) { + free(phdr); return -1; + } } 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); if (check_size(in, shdr->sh_offset, buffer_size(b), "strtab")) { ERROR("STRTAB section not within bounds: %d\n", i); + free(b); return -1; } pelf->strtabs[i] = b; |