diff options
author | Yann Collet <cyan@fb.com> | 2022-07-01 09:27:43 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2022-07-01 09:55:47 (GMT) |
commit | 49e63cd52202b1bbda2dc97309eb2e25a3677983 (patch) | |
tree | 8103fc0c693c3f209508d49b3292bd6234b36f26 | |
parent | 149644df49ba112daeff85f0bed229253516cc8c (diff) | |
download | lz4-49e63cd52202b1bbda2dc97309eb2e25a3677983.zip lz4-49e63cd52202b1bbda2dc97309eb2e25a3677983.tar.gz lz4-49e63cd52202b1bbda2dc97309eb2e25a3677983.tar.bz2 |
fixed minor leak
-rw-r--r-- | programs/lz4cli.c | 10 | ||||
-rw-r--r-- | programs/util.h | 4 | ||||
-rw-r--r-- | tests/Makefile | 2 |
3 files changed, 6 insertions, 10 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 45f88f4..254a6ce 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -331,9 +331,8 @@ int main(int argc, const char** argv) const char extension[] = LZ4_EXTENSION; size_t blockSize = LZ4IO_setBlockSizeID(prefs, LZ4_BLOCKSIZEID_DEFAULT); const char* const exeName = lastNameFromPath(argv[0]); -#ifdef UTIL_HAS_CREATEFILELIST - const char** extendedFileList = NULL; char* fileNamesBuf = NULL; +#ifdef UTIL_HAS_CREATEFILELIST unsigned fileNamesNb, recursive=0; #endif @@ -622,7 +621,7 @@ int main(int argc, const char** argv) input_filename = inFileNames[0]; #ifdef UTIL_HAS_CREATEFILELIST if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */ - extendedFileList = UTIL_createFileList(inFileNames, ifnIdx, &fileNamesBuf, &fileNamesNb); + const char** extendedFileList = UTIL_createFileList(inFileNames, ifnIdx, &fileNamesBuf, &fileNamesNb); if (extendedFileList) { unsigned u; for (u=0; u<fileNamesNb; u++) DISPLAYLEVEL(4, "%u %s\n", u, extendedFileList[u]); @@ -770,10 +769,7 @@ int main(int argc, const char** argv) _cleanup: if (main_pause) waitEnter(); free(dynNameSpace); -#ifdef UTIL_HAS_CREATEFILELIST - UTIL_freeFileList(extendedFileList, fileNamesBuf); - inFileNames = NULL; -#endif + free(fileNamesBuf); LZ4IO_freePreferences(prefs); free((void*)inFileNames); return operationResult; diff --git a/programs/util.h b/programs/util.h index 99bcca9..3192ddc 100644 --- a/programs/util.h +++ b/programs/util.h @@ -685,8 +685,8 @@ UTIL_createFileList(const char** inputNames, unsigned inputNamesNb, UTIL_STATIC void UTIL_freeFileList(const char** filenameTable, char* allocatedBuffer) { - if (allocatedBuffer) free(allocatedBuffer); - if (filenameTable) free((void*)filenameTable); + free(allocatedBuffer); + free((void*)filenameTable); } diff --git a/tests/Makefile b/tests/Makefile index 952defd..b67f135 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -293,7 +293,7 @@ test-lz4-multiple: lz4 datagen # test lz4-compressed file $(LZ4) -tm tmp-tlm-concat1.lz4 $(LZ4) -tm tmp-tlm-concat1.lz4 tmp-tlm-concat2.lz4 - # compress multiple lz4 files, one of which is absent (must fail) + # test multiple lz4 files, one of which is absent (must fail) ! $(LZ4) -tm tmp-tlm-concat1.lz4 notHere.lz4 tmp-tlm-concat2.lz4 @$(RM) tmp-tlm* |