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 /programs | |
parent | 149644df49ba112daeff85f0bed229253516cc8c (diff) | |
download | lz4-49e63cd52202b1bbda2dc97309eb2e25a3677983.zip lz4-49e63cd52202b1bbda2dc97309eb2e25a3677983.tar.gz lz4-49e63cd52202b1bbda2dc97309eb2e25a3677983.tar.bz2 |
fixed minor leak
Diffstat (limited to 'programs')
-rw-r--r-- | programs/lz4cli.c | 10 | ||||
-rw-r--r-- | programs/util.h | 4 |
2 files changed, 5 insertions, 9 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); } |