Skip to content

Commit 768b772

Browse files
committed
igzip: [SHIM] fix memory leaks
Signed-off-by: Pablo de Lara <[email protected]>
1 parent 8f2c02a commit 768b772

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

igzip/shim/shim_deflate.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,15 @@ deflateInit2_(z_streamp strm, int level, int method, int windowBits, int memLeve
8181
return -1;
8282
}
8383

84+
if (!isal_strm->level_buf) {
85+
free(isal_strm);
86+
fprintf(stderr, "Error: Memory allocation for level_buf failed\n");
87+
return -1;
88+
}
8489
deflate_state *s = (deflate_state *) malloc(sizeof(deflate_state));
8590
if (!s) {
91+
free(isal_strm->level_buf);
92+
free(isal_strm);
8693
fprintf(stderr, "Error: Memory allocation for deflate_state failed\n");
8794
return -1;
8895
}

igzip/shim/shim_inflate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ inflateInit2_(z_streamp strm, int windowBits)
6161

6262
inflate_state2 *s = (inflate_state2 *) malloc(sizeof(inflate_state2));
6363
if (!s) {
64+
free(isal_strm_inflate);
6465
fprintf(stderr, "Error: Memory allocation for inflate_state2 failed\n");
6566
return -1;
6667
}
@@ -210,6 +211,7 @@ inflateEnd(z_streamp strm)
210211
}
211212

212213
inflate_state2 *s = (inflate_state2 *) strm->state;
214+
free(s->isal_strm_inflate);
213215
free(s);
214216

215217
strm->state = NULL;

0 commit comments

Comments
 (0)