cbfstool: cbfs-mkstage.c: Free `buffer` on error path

Cppcheck warns about a memory leak, present since adding romtool,
which was renamed to cbfstool, in commit 5d01ec0f.

    $ cppcheck --version
    Cppcheck 1.59
    […]
    [cbfs-mkstage.c:170]: (error) Memory leak: buffer
    […]

Indeed the memory pointed to by `buffer` is not freed on the error path,
so add `free(buffer)` to fix this.

Change-Id: I6cbf82479027747c800c5fe847f20b779e261ef4
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/3069
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Paul Menzel 2013-04-11 10:45:11 +02:00 committed by Stefan Reinauer
parent e76d8d7ced
commit 2c8f81b57b
1 changed files with 1 additions and 0 deletions

View File

@ -167,6 +167,7 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
if (buffer_create(output, sizeof(*stage) + data_end - data_start,
input->name) != 0) {
ERROR("Unable to allocate memory: %m\n");
free(buffer);
return -1;
}
memset(output->data, 0, output->size);