summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorSolomon Alan-Dei <alandei.solomon@gmail.com>2022-10-30 03:49:59 -0600
committerFelix Held <felix-coreboot@felixheld.de>2022-11-02 21:40:25 +0000
commitb4e94c8b0160f52cf9520521628558382063f122 (patch)
treecaae1f85062d1c888fb19d3b13aaa108e28d4109 /util
parentbb4b793f4a2a86cfbefbf9cd3b4f4b05b4183a0d (diff)
downloadcoreboot-b4e94c8b0160f52cf9520521628558382063f122.tar.gz
coreboot-b4e94c8b0160f52cf9520521628558382063f122.tar.bz2
coreboot-b4e94c8b0160f52cf9520521628558382063f122.zip
util/cbfstool: fix memory leak in compress.c
free the memory allocated in lz4_compress function before returning from it. Reported-by: Coverity (CID:1469433) Signed-off-by: Solomon Alan-Dei <alandei.solomon@gmail.com> Change-Id: I8698090d519964348e51fc3b6f2023d06d81fcd5 Reviewed-on: https://review.coreboot.org/c/coreboot/+/69021 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/cbfstool/compress.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/util/cbfstool/compress.c b/util/cbfstool/compress.c
index 37fac224ccd1..96df1a74991f 100644
--- a/util/cbfstool/compress.c
+++ b/util/cbfstool/compress.c
@@ -23,9 +23,12 @@ static int lz4_compress(char *in, int in_len, char *out, int *out_len)
if (!bounce)
return -1;
*out_len = LZ4F_compressFrame(bounce, worst_size, in, in_len, &prefs);
- if (LZ4F_isError(*out_len) || *out_len >= in_len)
+ if (LZ4F_isError(*out_len) || *out_len >= in_len) {
+ free(bounce);
return -1;
+ }
memcpy(out, bounce, *out_len);
+ free(bounce);
return 0;
}