Skip to content

Commit

Permalink
[bug] fix memory leakage lloyd/easylzma#4 and lloyd/easylzma#7, close #…
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Aug 18, 2024
1 parent d756c37 commit 66c8e88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example/c/testzmat.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(void) {
/*=====================================*/

/*first, perform zlib compression use the highest compression (-9); one can use zmat_encode as well*/
ret = zmat_run(strlen(test[0]), (unsigned char*)test[0], &compressedlen, &compressed, zmZlib, &status, flags.iscompress);
ret = zmat_run(strlen(test[0]), (unsigned char*)test[0], &compressedlen, &compressed, zmLzma, &status, flags.iscompress);

if (ret == 0) {
/*next, encode the compressed data using base64*/
Expand Down Expand Up @@ -68,7 +68,7 @@ int main(void) {

if (ret == 0) {
/*next, decompress using zlib (deflate) */
ret = zmat_decode(decodelen, decoded, &decompressedlen, &decompressed, zmZlib, &status);
ret = zmat_decode(decodelen, decoded, &decompressedlen, &decompressed, zmLzma, &status);

if (ret == 0) {
printf("\t\"decompressed\":\"%s\",\n", decompressed);
Expand Down
4 changes: 4 additions & 0 deletions src/zmatlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ simpleCompress(elzma_file_format format, const unsigned char* inData,
*outLen = ds.outLen;
}

elzma_compress_free(&hand);

return rc;
}

Expand Down Expand Up @@ -1009,6 +1011,8 @@ simpleDecompress(elzma_file_format format, const unsigned char* inData,
return rc;
}

elzma_decompress_free(&hand);

*outData = ds.outData;
*outLen = ds.outLen;
}
Expand Down

0 comments on commit 66c8e88

Please sign in to comment.