diff options
author | Patrick Georgi <pgeorgi@chromium.org> | 2017-01-13 13:30:54 +0100 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2017-03-20 20:05:09 +0100 |
commit | dce629b2f8260010a06ea5a9bd31f5c65f483f3d (patch) | |
tree | e115338fc2b00d1c9820414afd33e2bb8608fd34 /util/cbfstool/cbfscomptool.c | |
parent | 1dfc0a64d42cc9052f5140cfa481ec0380971eef (diff) | |
download | coreboot-dce629b2f8260010a06ea5a9bd31f5c65f483f3d.tar.xz |
util/cbfstool: avoid memleaks and off-by-ones
Change-Id: Iac136a5dfe76f21aa7c0d5ee4e974e50b955403b
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Found-by: scan-build 3.8
Reviewed-on: https://review.coreboot.org/18134
Tested-by: build bot (Jenkins)
Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'util/cbfstool/cbfscomptool.c')
-rw-r--r-- | util/cbfstool/cbfscomptool.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/util/cbfstool/cbfscomptool.c b/util/cbfstool/cbfscomptool.c index 9e804860a9..3430809e0d 100644 --- a/util/cbfstool/cbfscomptool.c +++ b/util/cbfstool/cbfscomptool.c @@ -49,6 +49,7 @@ int benchmark() } char *compressed_data = malloc(bufsize); if (!compressed_data) { + free(data); fprintf(stderr, "out of memory\n"); return 1; } @@ -64,6 +65,8 @@ int benchmark() comp_func_ptr comp = compression_function(algo->type); if (comp == NULL) { printf("no handler associated with algorithm\n"); + free(data); + free(compressed_data); return 1; } @@ -80,6 +83,8 @@ int benchmark() bufsize, outsize, t_e.tv_sec - t_s.tv_sec); } + free(data); + free(compressed_data); return 0; } |