Skip to content

Commit 66c8e88

Browse files
committed
[bug] fix memory leakage lloyd/easylzma#4 and lloyd/easylzma#7, close #11
1 parent d756c37 commit 66c8e88

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

example/c/testzmat.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int main(void) {
3636
/*=====================================*/
3737

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

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

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

7373
if (ret == 0) {
7474
printf("\t\"decompressed\":\"%s\",\n", decompressed);

src/zmatlib.c

+4
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,8 @@ simpleCompress(elzma_file_format format, const unsigned char* inData,
965965
*outLen = ds.outLen;
966966
}
967967

968+
elzma_compress_free(&hand);
969+
968970
return rc;
969971
}
970972

@@ -1009,6 +1011,8 @@ simpleDecompress(elzma_file_format format, const unsigned char* inData,
10091011
return rc;
10101012
}
10111013

1014+
elzma_decompress_free(&hand);
1015+
10121016
*outData = ds.outData;
10131017
*outLen = ds.outLen;
10141018
}

0 commit comments

Comments
 (0)