mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
We're freeing the wrong buffer by mistake should decompression fail.
This commit is contained in:
parent
4314970b0d
commit
2d2a9bc1e9
24
stream.c
24
stream.c
|
|
@ -510,8 +510,10 @@ static int bzip2_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_
|
|||
bzerr = BZ2_bzBuffToBuffDecompress((char*)ucthread->s_buf, &dlen, (char*)c_buf, ucthread->c_len, 0, 0);
|
||||
if (unlikely(bzerr != BZ_OK)) {
|
||||
print_err("Failed to decompress buffer - bzerr=%d\n", bzerr);
|
||||
free(ucthread->s_buf);
|
||||
ucthread->s_buf = c_buf;
|
||||
ret = -1;
|
||||
goto out_free;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (unlikely(dlen != ucthread->u_len)) {
|
||||
|
|
@ -519,7 +521,6 @@ static int bzip2_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
out_free:
|
||||
free(c_buf);
|
||||
out:
|
||||
if (ret == -1)
|
||||
|
|
@ -543,9 +544,11 @@ static int gzip_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_t
|
|||
|
||||
gzerr = uncompress(ucthread->s_buf, &dlen, c_buf, ucthread->c_len);
|
||||
if (unlikely(gzerr != Z_OK)) {
|
||||
print_err("Failed to decompress buffer - bzerr=%d\n", gzerr);
|
||||
print_err("Failed to decompress buffer - gzerr=%d\n", gzerr);
|
||||
free(ucthread->s_buf);
|
||||
ucthread->s_buf = c_buf;
|
||||
ret = -1;
|
||||
goto out_free;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (unlikely((i64)dlen != ucthread->u_len)) {
|
||||
|
|
@ -553,7 +556,6 @@ static int gzip_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_t
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
out_free:
|
||||
free(c_buf);
|
||||
out:
|
||||
if (ret == -1)
|
||||
|
|
@ -580,8 +582,10 @@ static int lzma_decompress_buf(rzip_control *control, struct uncomp_thread *ucth
|
|||
lzmaerr = LzmaUncompress(ucthread->s_buf, &dlen, c_buf, (SizeT *)&ucthread->c_len, control->lzma_properties, 5);
|
||||
if (unlikely(lzmaerr)) {
|
||||
print_err("Failed to decompress buffer - lzmaerr=%d\n", lzmaerr);
|
||||
free(ucthread->s_buf);
|
||||
ucthread->s_buf = c_buf;
|
||||
ret = -1;
|
||||
goto out_free;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (unlikely((i64)dlen != ucthread->u_len)) {
|
||||
|
|
@ -589,7 +593,6 @@ static int lzma_decompress_buf(rzip_control *control, struct uncomp_thread *ucth
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
out_free:
|
||||
free(c_buf);
|
||||
out:
|
||||
if (ret == -1)
|
||||
|
|
@ -611,11 +614,13 @@ static int lzo_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_th
|
|||
goto out;
|
||||
}
|
||||
|
||||
lzerr = lzo1x_decompress((uchar*)c_buf, ucthread->c_len, (uchar*)ucthread->s_buf, &dlen,NULL);
|
||||
lzerr = lzo1x_decompress((uchar*)c_buf, ucthread->c_len, (uchar*)ucthread->s_buf, &dlen, NULL);
|
||||
if (unlikely(lzerr != LZO_E_OK)) {
|
||||
print_err("Failed to decompress buffer - lzerr=%d\n", lzerr);
|
||||
free(ucthread->s_buf);
|
||||
ucthread->s_buf = c_buf;
|
||||
ret = -1;
|
||||
goto out_free;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (unlikely((i64)dlen != ucthread->u_len)) {
|
||||
|
|
@ -623,7 +628,6 @@ static int lzo_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_th
|
|||
ret = -1;
|
||||
}
|
||||
|
||||
out_free:
|
||||
free(c_buf);
|
||||
out:
|
||||
if (ret == -1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue