If call to inflateInit2() fails, release the memory allocated for buff
before returning.

Signed-off-by: Sandeep Dhavale <[email protected]>
---
 lib/decompress.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/decompress.c b/lib/decompress.c
index 01f0141..fe8a40c 100644
--- a/lib/decompress.c
+++ b/lib/decompress.c
@@ -126,8 +126,10 @@ static int z_erofs_decompress_deflate(struct 
z_erofs_decompress_req *rq)
        strm.avail_in = 0;
        strm.next_in = Z_NULL;
        ret = inflateInit2(&strm, -15);
-       if (ret != Z_OK)
+       if (ret != Z_OK) {
+               free(buff);
                return zerr(ret);
+       }
 
        strm.next_in = src + inputmargin;
        strm.avail_in = rq->inputsize - inputmargin;
-- 
2.42.0.283.g2d96d420d3-goog

Reply via email to