zstd-1.5.7-1.fc43

List of Findings

Error: GCC_ANALYZER_WARNING (CWE-415): [#def1]
zstd-1.5.7/contrib/pzstd/../../programs/util.c:103:5: warning[-Wanalyzer-double-free]: double-‘free’ of ‘ptr’
zstd-1.5.7/contrib/pzstd/../../programs/util.c:1339:6: enter_function: entry to ‘UTIL_expandFNT’
zstd-1.5.7/contrib/pzstd/../../programs/util.c:1341:36: call_function: calling ‘UTIL_createExpandedFNT’ from ‘UTIL_expandFNT’
#  101|       void *newptr = realloc(ptr, size);
#  102|       if (newptr) return newptr;
#  103|->     free(ptr);
#  104|       return NULL;
#  105|   }

Error: CPPCHECK_WARNING (CWE-404): [#def2]
zstd-1.5.7/contrib/pzstd/Pzstd.cpp:127: error[resourceLeak]: Resource leak: inputFd
#  125|     auto inputFd = std::fopen(inputFile.c_str(), "rb");
#  126|     if (!errorHolder.check(inputFd != nullptr, "Failed to open input file")) {
#  127|->     return nullptr;
#  128|     }
#  129|     return inputFd;

Error: CPPCHECK_WARNING (CWE-404): [#def3]
zstd-1.5.7/contrib/pzstd/Pzstd.cpp:162: error[resourceLeak]: Resource leak: outputFd
#  160|     if (!state.errorHolder.check(
#  161|             outputFd != nullptr, "Failed to open output file")) {
#  162|->     return nullptr;
#  163|     }
#  164|     return outputFd;

Error: GCC_ANALYZER_WARNING (CWE-457): [#def4]
zstd-1.5.7/lib//compress/zstd_compress.c:2809:24: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘stats.Offtype’
zstd-1.5.7/lib//compress/zstd_compress.c:4883:8: enter_function: entry to ‘ZSTD_compressBlock_deprecated’
zstd-1.5.7/lib//compress/zstd_compress.c:4889:12: call_function: calling ‘ZSTD_compressContinue_internal’ from ‘ZSTD_compressBlock_deprecated’
# 2807|                   DEBUGLOG(3, "ZSTD_buildCTable for LitLens failed");
# 2808|                   stats.size = countSize;
# 2809|->                 return stats;
# 2810|               }
# 2811|               if (stats.LLtype == set_compressed)

Error: GCC_ANALYZER_WARNING (CWE-457): [#def5]
zstd-1.5.7/lib//compress/zstd_compress.c:2841:24: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘stats.MLtype’
zstd-1.5.7/lib//compress/zstd_compress.c:4883:8: enter_function: entry to ‘ZSTD_compressBlock_deprecated’
zstd-1.5.7/lib//compress/zstd_compress.c:4889:12: call_function: calling ‘ZSTD_compressContinue_internal’ from ‘ZSTD_compressBlock_deprecated’
# 2839|                   DEBUGLOG(3, "ZSTD_buildCTable for Offsets failed");
# 2840|                   stats.size = countSize;
# 2841|->                 return stats;
# 2842|               }
# 2843|               if (stats.Offtype == set_compressed)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
zstd-1.5.7/lib//compress/zstdmt_compress.c:224:16: warning[-Wanalyzer-malloc-leak]: leak of ‘<return-value>.start’
zstd-1.5.7/lib//compress/zstdmt_compress.c:1403:15: enter_function: entry to ‘ZSTDMT_createCompressionJob’
zstd-1.5.7/lib//compress/zstdmt_compress.c:1408:8: branch_false: following ‘false’ branch...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1414:10: branch_false: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1414:8: branch_true: following ‘true’ branch...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1415:21: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1443:12: branch_true: following ‘true’ branch (when ‘endOp != 2’)...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1444:42: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1455:12: branch_true: following ‘true’ branch (when ‘srcSize == 0’)...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1455:14: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1455:14: branch_true: following ‘true’ branch...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1459:13: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1459:13: call_function: calling ‘ZSTDMT_writeLastEmptyBlock’ from ‘ZSTDMT_createCompressionJob’
#  222|               DEBUGLOG(5, "ZSTDMT_getBuffer: created buffer of size %u", (U32)bSize);
#  223|           }
#  224|->         return buffer;
#  225|       }
#  226|   }

Error: GCC_ANALYZER_WARNING (CWE-401): [#def7]
zstd-1.5.7/lib//compress/zstdmt_compress.c:224:16: warning[-Wanalyzer-malloc-leak]: leak of ‘<unknown>’
zstd-1.5.7/lib//compress/zstdmt_compress.c:1403:15: enter_function: entry to ‘ZSTDMT_createCompressionJob’
zstd-1.5.7/lib//compress/zstdmt_compress.c:1408:8: branch_false: following ‘false’ branch...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1414:10: branch_false: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1414:8: branch_true: following ‘true’ branch...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1415:21: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1443:12: branch_true: following ‘true’ branch (when ‘endOp != 2’)...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1444:42: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1455:12: branch_true: following ‘true’ branch (when ‘srcSize == 0’)...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1456:15: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1455:14: branch_true: following ‘true’ branch...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1459:13: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1459:13: call_function: calling ‘ZSTDMT_writeLastEmptyBlock’ from ‘ZSTDMT_createCompressionJob’
#  222|               DEBUGLOG(5, "ZSTDMT_getBuffer: created buffer of size %u", (U32)bSize);
#  223|           }
#  224|->         return buffer;
#  225|       }
#  226|   }

Error: GCC_ANALYZER_WARNING (CWE-835): [#def8]
zstd-1.5.7/lib//compress/zstdmt_compress.c:1035:27: warning[-Wanalyzer-infinite-loop]: infinite loop
zstd-1.5.7/lib//compress/zstdmt_compress.c:1488:15: enter_function: entry to ‘ZSTDMT_flushProduced’
# 1033|           unsigned const jobID = mtctx->doneJobID & mtctx->jobIDMask;
# 1034|           ZSTD_PTHREAD_MUTEX_LOCK(&mtctx->jobs[jobID].job_mutex);
# 1035|->         while (mtctx->jobs[jobID].consumed < mtctx->jobs[jobID].src.size) {
# 1036|               DEBUGLOG(4, "waiting for jobCompleted signal from job %u", mtctx->doneJobID);   /* we want to block when waiting for data to flush */
# 1037|               ZSTD_pthread_cond_wait(&mtctx->jobs[jobID].job_cond, &mtctx->jobs[jobID].job_mutex);

Error: GCC_ANALYZER_WARNING (CWE-835): [#def9]
zstd-1.5.7/lib//compress/zstdmt_compress.c:1499:27: warning[-Wanalyzer-infinite-loop]: infinite loop
zstd-1.5.7/lib//compress/zstdmt_compress.c:1499:27: danger: infinite loop here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1499:16: branch_true: if it ever follows ‘true’ branch, it will always do so...
zstd-1.5.7/lib//compress/zstdmt_compress.c:1500:17: branch_true: ...to here
zstd-1.5.7/lib//compress/zstdmt_compress.c:1500:16: branch_false: if it ever follows ‘false’ branch, it will always do so...
 branch_false: ...to here
# 1497|         && (mtctx->doneJobID < mtctx->nextJobID) ) {
# 1498|           assert(mtctx->jobs[wJobID].dstFlushed <= mtctx->jobs[wJobID].cSize);
# 1499|->         while (mtctx->jobs[wJobID].dstFlushed == mtctx->jobs[wJobID].cSize) {  /* nothing to flush */
# 1500|               if (mtctx->jobs[wJobID].consumed == mtctx->jobs[wJobID].src.size) {
# 1501|                   DEBUGLOG(5, "job %u is completely consumed (%u == %u) => don't wait for cond, there will be none",

Error: GCC_ANALYZER_WARNING (CWE-835): [#def10]
zstd-1.5.7/lib//dictBuilder/cover.c:914:10: warning[-Wanalyzer-infinite-loop]: infinite loop
zstd-1.5.7/lib//dictBuilder/cover.c:914:10: danger: infinite loop here
zstd-1.5.7/lib//dictBuilder/cover.c:914:10: branch_true: if it ever follows ‘true’ branch, it will always do so...
 branch_true: ...to here
#  912|     }
#  913|     ZSTD_pthread_mutex_lock(&best->mutex);
#  914|->   while (best->liveJobs != 0) {
#  915|       ZSTD_pthread_cond_wait(&best->cond, &best->mutex);
#  916|     }

Error: GCC_ANALYZER_WARNING (CWE-457): [#def11]
zstd-1.5.7/lib//dictBuilder/cover.c:1039:3: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘customDictContent’
zstd-1.5.7/lib//dictBuilder/cover.c:1122:13: enter_function: entry to ‘COVER_tryParameters’
zstd-1.5.7/lib//dictBuilder/cover.c:1135:8: call_function: calling ‘COVER_map_init’ from ‘COVER_tryParameters’
zstd-1.5.7/lib//dictBuilder/cover.c:1135:8: return_function: returning to ‘COVER_tryParameters’ from ‘COVER_map_init’
zstd-1.5.7/lib//dictBuilder/cover.c:1135:6: branch_false: following ‘false’ branch...
zstd-1.5.7/lib//dictBuilder/cover.c:1139:7: branch_false: ...to here
zstd-1.5.7/lib//dictBuilder/cover.c:1139:6: branch_false: following ‘false’ branch...
zstd-1.5.7/lib//dictBuilder/cover.c:1144:29: branch_false: ...to here
zstd-1.5.7/lib//dictBuilder/cover.c:1147:25: call_function: calling ‘COVER_buildDictionary’ from ‘COVER_tryParameters’
zstd-1.5.7/lib//dictBuilder/cover.c:1147:25: return_function: returning to ‘COVER_tryParameters’ from ‘COVER_buildDictionary’
zstd-1.5.7/lib//dictBuilder/cover.c:1149:17: call_function: calling ‘COVER_selectDict’ from ‘COVER_tryParameters’
# 1037|   
# 1038|     /* Initial dictionary size and compressed size */
# 1039|->   memcpy(largestDictbuffer, customDictContent, dictContentSize);
# 1040|     dictContentSize = ZDICT_finalizeDictionary(
# 1041|       largestDictbuffer, dictBufferCapacity, customDictContent, dictContentSize,

Error: CPPCHECK_WARNING (CWE-457): [#def12]
zstd-1.5.7/lib/compress/zstd_compress.c:2809: error[uninitvar]: Uninitialized variables: stats.Offtype, stats.MLtype
# 2807|                   DEBUGLOG(3, "ZSTD_buildCTable for LitLens failed");
# 2808|                   stats.size = countSize;
# 2809|->                 return stats;
# 2810|               }
# 2811|               if (stats.LLtype == set_compressed)

Error: CPPCHECK_WARNING (CWE-457): [#def13]
zstd-1.5.7/lib/compress/zstd_compress.c:7465: error[uninitvar]: Uninitialized variables: bs.blockSize, bs.litSize
# 7463|           BlockSummary bs;
# 7464|           bs.nbSequences = ERROR(externalSequences_invalid);
# 7465|->         return bs;
# 7466|       }
# 7467|       {   BlockSummary bs;

Error: CPPCHECK_WARNING (CWE-457): [#def14]
zstd-1.5.7/lib/decompress/zstd_decompress.c:731: error[uninitvar]: Uninitialized variable: frameSizeInfo.nbBlocks
#  729|       frameSizeInfo.compressedSize = ret;
#  730|       frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR;
#  731|->     return frameSizeInfo;
#  732|   }
#  733|   

Error: CPPCHECK_WARNING (CWE-682): [#def15]
zstd-1.5.7/lib/dictBuilder/zdict.c:471: error[nullPointerArithmeticOutOfMemory]: If memory allocation fail: pointer addition with NULL pointer.
#  469|   {
#  470|       int* const suffix0 = (int*)malloc((bufferSize+2)*sizeof(*suffix0));
#  471|->     int* const suffix = suffix0+1;
#  472|       U32* reverseSuffix = (U32*)malloc((bufferSize)*sizeof(*reverseSuffix));
#  473|       BYTE* doneMarks = (BYTE*)malloc((bufferSize+16)*sizeof(*doneMarks));   /* +16 for overflow security */

Error: CPPCHECK_WARNING (CWE-457): [#def16]
zstd-1.5.7/programs/benchfn.c:97: error[uninitvar]: Uninitialized variable: outcome.error_result_never_ever_use_directly
#   95|       outcome.error_tag_never_ever_use_directly = 0;
#   96|       outcome.internal_never_ever_use_directly = runTime;
#   97|->     return outcome;
#   98|   }
#   99|   

Error: GCC_ANALYZER_WARNING (CWE-457): [#def17]
zstd-1.5.7/programs/benchfn.c:97:12: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘outcome.error_result_never_ever_use_directly’
zstd-1.5.7/programs/benchfn.c:144:20: call_function: inlined call to ‘BMK_setValid_runTime’ from ‘BMK_benchFunction’
#   95|       outcome.error_tag_never_ever_use_directly = 0;
#   96|       outcome.internal_never_ever_use_directly = runTime;
#   97|->     return outcome;
#   98|   }
#   99|   

Error: GCC_ANALYZER_WARNING (CWE-126): [#def18]
zstd-1.5.7/programs/benchzstd.c:1076:27: warning[-Wanalyzer-out-of-bounds]: stack-based buffer over-read
zstd-1.5.7/programs/benchzstd.c:1125:5: enter_function: entry to ‘BMK_benchFilesAdvanced’
zstd-1.5.7/programs/benchzstd.c:1142:8: branch_false: following ‘false’ branch (when ‘nbFiles != 0’)...
zstd-1.5.7/programs/benchzstd.c:1147:21: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1147:8: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/benchzstd.c:1152:8: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1152:8: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/benchzstd.c:1157:26: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1158:8: branch_false: following ‘false’ branch (when ‘fileSizes’ is non-NULL)...
zstd-1.5.7/programs/benchzstd.c:1164:9: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1164:8: branch_true: following ‘true’ branch...
zstd-1.5.7/programs/benchzstd.c:1165:34: branch_true: ...to here
zstd-1.5.7/programs/benchzstd.c:1166:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/benchzstd.c:1176:12: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1176:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/benchzstd.c:1182:26: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1183:12: branch_false: following ‘false’ branch (when ‘dictBuffer’ is non-NULL)...
zstd-1.5.7/programs/benchzstd.c:1193:35: branch_false: ...to here
zstd-1.5.7/programs/benchzstd.c:1193:35: call_function: calling ‘BMK_loadFiles’ from ‘BMK_benchFilesAdvanced’
# 1074|       unsigned n;
# 1075|       for (n = 0; n < nbFiles; n++) {
# 1076|->         const char* const filename = fileNamesTable[n];
# 1077|           U64 fileSize = UTIL_getFileSize(
# 1078|                   filename); /* last file may be shortened */

Error: GCC_ANALYZER_WARNING (CWE-775): [#def19]
zstd-1.5.7/programs/dibio.c:144:37: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(*<unknown>, "rb")’
zstd-1.5.7/programs/dibio.c:128:13: branch_true: following ‘true’ branch...
zstd-1.5.7/programs/dibio.c:130:60: branch_true: ...to here
zstd-1.5.7/programs/dibio.c:131:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:137:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:137:13: acquire_resource: opened here
zstd-1.5.7/programs/dibio.c:138:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:140:9: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:143:26: branch_true: following ‘true’ branch (when ‘targetChunkSize != 0’)...
zstd-1.5.7/programs/dibio.c:144:37: branch_true: ...to here
zstd-1.5.7/programs/dibio.c:146:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:148:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:144:37: danger: ‘fopen(*<unknown>, "rb")’ leaks here; was opened at [(5)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/4)
#  142|           /* Load the first chunk of data from the file */
#  143|           fileDataLoaded = targetChunkSize > 0 ?
#  144|->                             (size_t)MIN(fileSize, (S64)targetChunkSize) :
#  145|                               (size_t)MIN(fileSize, SAMPLESIZE_MAX );
#  146|           if (totalDataLoaded + fileDataLoaded > *bufferSizePtr)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def20]
zstd-1.5.7/programs/dibio.c:144:37: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(*<unknown>, "rb")’
zstd-1.5.7/programs/dibio.c:128:13: branch_true: following ‘true’ branch...
zstd-1.5.7/programs/dibio.c:130:60: branch_true: ...to here
zstd-1.5.7/programs/dibio.c:131:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:137:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:137:13: acquire_memory: allocated here
zstd-1.5.7/programs/dibio.c:138:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:140:9: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:143:26: branch_true: following ‘true’ branch (when ‘targetChunkSize != 0’)...
zstd-1.5.7/programs/dibio.c:144:37: branch_true: ...to here
zstd-1.5.7/programs/dibio.c:146:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:148:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:144:37: danger: ‘fopen(*<unknown>, "rb")’ leaks here; was allocated at [(5)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/4)
#  142|           /* Load the first chunk of data from the file */
#  143|           fileDataLoaded = targetChunkSize > 0 ?
#  144|->                             (size_t)MIN(fileSize, (S64)targetChunkSize) :
#  145|                               (size_t)MIN(fileSize, SAMPLESIZE_MAX );
#  146|           if (totalDataLoaded + fileDataLoaded > *bufferSizePtr)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def21]
zstd-1.5.7/programs/dibio.c:146:13: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(*<unknown>, "rb")’
zstd-1.5.7/programs/dibio.c:128:13: branch_true: following ‘true’ branch...
zstd-1.5.7/programs/dibio.c:130:60: branch_true: ...to here
zstd-1.5.7/programs/dibio.c:131:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:137:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:137:13: acquire_resource: opened here
zstd-1.5.7/programs/dibio.c:138:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:140:9: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:143:26: branch_false: following ‘false’ branch (when ‘targetChunkSize == 0’)...
zstd-1.5.7/programs/dibio.c:143:26: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:146:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:148:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:146:13: danger: ‘fopen(*<unknown>, "rb")’ leaks here; was opened at [(5)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/4)
#  144|                               (size_t)MIN(fileSize, (S64)targetChunkSize) :
#  145|                               (size_t)MIN(fileSize, SAMPLESIZE_MAX );
#  146|->         if (totalDataLoaded + fileDataLoaded > *bufferSizePtr)
#  147|               break;
#  148|           if (fread( buff+totalDataLoaded, 1, fileDataLoaded, f ) != fileDataLoaded)

Error: GCC_ANALYZER_WARNING (CWE-401): [#def22]
zstd-1.5.7/programs/dibio.c:146:13: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(*<unknown>, "rb")’
zstd-1.5.7/programs/dibio.c:128:13: branch_true: following ‘true’ branch...
zstd-1.5.7/programs/dibio.c:130:60: branch_true: ...to here
zstd-1.5.7/programs/dibio.c:131:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:137:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:137:13: acquire_memory: allocated here
zstd-1.5.7/programs/dibio.c:138:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:140:9: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:143:26: branch_false: following ‘false’ branch (when ‘targetChunkSize == 0’)...
zstd-1.5.7/programs/dibio.c:143:26: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:146:12: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:148:13: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:146:13: danger: ‘fopen(*<unknown>, "rb")’ leaks here; was allocated at [(5)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/4)
#  144|                               (size_t)MIN(fileSize, (S64)targetChunkSize) :
#  145|                               (size_t)MIN(fileSize, SAMPLESIZE_MAX );
#  146|->         if (totalDataLoaded + fileDataLoaded > *bufferSizePtr)
#  147|               break;
#  148|           if (fread( buff+totalDataLoaded, 1, fileDataLoaded, f ) != fileDataLoaded)

Error: GCC_ANALYZER_WARNING (CWE-775): [#def23]
zstd-1.5.7/programs/dibio.c:254:10: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(dictFileName, "wb")’
zstd-1.5.7/programs/dibio.c:250:21: acquire_resource: opened here
zstd-1.5.7/programs/dibio.c:251:8: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:253:24: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:254:10: danger: ‘fopen(dictFileName, "wb")’ leaks here; was opened at [(1)](sarif:/runs/0/results/6/codeFlows/0/threadFlows/0/locations/0)
#  252|   
#  253|       { size_t const n = fwrite(buff, 1, buffSize, f);
#  254|->       if (n!=buffSize) EXM_THROW(4, "%s : write error", dictFileName) }
#  255|   
#  256|       { size_t const n = (size_t)fclose(f);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def24]
zstd-1.5.7/programs/dibio.c:254:10: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(dictFileName, "wb")’
zstd-1.5.7/programs/dibio.c:250:21: acquire_memory: allocated here
zstd-1.5.7/programs/dibio.c:251:8: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/dibio.c:253:24: branch_false: ...to here
zstd-1.5.7/programs/dibio.c:254:10: danger: ‘fopen(dictFileName, "wb")’ leaks here; was allocated at [(1)](sarif:/runs/0/results/7/codeFlows/0/threadFlows/0/locations/0)
#  252|   
#  253|       { size_t const n = fwrite(buff, 1, buffSize, f);
#  254|->       if (n!=buffSize) EXM_THROW(4, "%s : write error", dictFileName) }
#  255|   
#  256|       { size_t const n = (size_t)fclose(f);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def25]
zstd-1.5.7/programs/fileio.c:724:59: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  722|       fileSize = UTIL_getFileSizeStat(dictFileStat);
#  723|       {
#  724|->         size_t const dictSizeMax = prefs->patchFromMode ? prefs->memLimit : DICTSIZE_MAX;
#  725|           if (fileSize >  dictSizeMax) {
#  726|               EXM_THROW(34, "Dictionary file %s is too large (> %u bytes)",

Error: GCC_ANALYZER_WARNING (CWE-401): [#def26]
zstd-1.5.7/programs/fileio.c:724:59: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  722|       fileSize = UTIL_getFileSizeStat(dictFileStat);
#  723|       {
#  724|->         size_t const dictSizeMax = prefs->patchFromMode ? prefs->memLimit : DICTSIZE_MAX;
#  725|           if (fileSize >  dictSizeMax) {
#  726|               EXM_THROW(34, "Dictionary file %s is too large (> %u bytes)",

Error: GCC_ANALYZER_WARNING (CWE-775): [#def27]
zstd-1.5.7/programs/fileio.c:725:12: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  723|       {
#  724|           size_t const dictSizeMax = prefs->patchFromMode ? prefs->memLimit : DICTSIZE_MAX;
#  725|->         if (fileSize >  dictSizeMax) {
#  726|               EXM_THROW(34, "Dictionary file %s is too large (> %u bytes)",
#  727|                               fileName,  (unsigned)dictSizeMax);   /* avoid extreme cases */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def28]
zstd-1.5.7/programs/fileio.c:725:12: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  723|       {
#  724|           size_t const dictSizeMax = prefs->patchFromMode ? prefs->memLimit : DICTSIZE_MAX;
#  725|->         if (fileSize >  dictSizeMax) {
#  726|               EXM_THROW(34, "Dictionary file %s is too large (> %u bytes)",
#  727|                               fileName,  (unsigned)dictSizeMax);   /* avoid extreme cases */

Error: GCC_ANALYZER_WARNING (CWE-775): [#def29]
zstd-1.5.7/programs/fileio.c:731:8: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  729|       }
#  730|       *bufferPtr = malloc((size_t)fileSize);
#  731|->     if (*bufferPtr==NULL) EXM_THROW(34, "%s", strerror(errno));
#  732|       {   size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fileHandle);
#  733|           if (readSize != fileSize) {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def30]
zstd-1.5.7/programs/fileio.c:731:8: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  729|       }
#  730|       *bufferPtr = malloc((size_t)fileSize);
#  731|->     if (*bufferPtr==NULL) EXM_THROW(34, "%s", strerror(errno));
#  732|       {   size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fileHandle);
#  733|           if (readSize != fileSize) {

Error: GCC_ANALYZER_WARNING (CWE-775): [#def31]
zstd-1.5.7/programs/fileio.c:733:12: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  731|       if (*bufferPtr==NULL) EXM_THROW(34, "%s", strerror(errno));
#  732|       {   size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fileHandle);
#  733|->         if (readSize != fileSize) {
#  734|               EXM_THROW(35, "Error reading dictionary file %s : %s",
#  735|                       fileName, strerror(errno));

Error: GCC_ANALYZER_WARNING (CWE-401): [#def32]
zstd-1.5.7/programs/fileio.c:733:12: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(fileName, "rb")’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  731|       if (*bufferPtr==NULL) EXM_THROW(34, "%s", strerror(errno));
#  732|       {   size_t const readSize = fread(*bufferPtr, 1, (size_t)fileSize, fileHandle);
#  733|->         if (readSize != fileSize) {
#  734|               EXM_THROW(35, "Error reading dictionary file %s : %s",
#  735|                       fileName, strerror(errno));

Error: GCC_ANALYZER_WARNING (CWE-775): [#def33]
zstd-1.5.7/programs/fileio.c:771:59: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(fileName, 0)’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  769|       fileSize = UTIL_getFileSizeStat(dictFileStat);
#  770|       {
#  771|->         size_t const dictSizeMax = prefs->patchFromMode ? prefs->memLimit : DICTSIZE_MAX;
#  772|           if (fileSize >  dictSizeMax) {
#  773|               EXM_THROW(34, "Dictionary file %s is too large (> %u bytes)",

Error: GCC_ANALYZER_WARNING (CWE-775): [#def34]
zstd-1.5.7/programs/fileio.c:772:12: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘open(fileName, 0)’
zstd-1.5.7/programs/fileio.c:3080:1: enter_function: entry to ‘FIO_decompressMultipleFilenames’
zstd-1.5.7/programs/fileio.c:3089:20: call_function: calling ‘FIO_createDResources’ from ‘FIO_decompressMultipleFilenames’
#  770|       {
#  771|           size_t const dictSizeMax = prefs->patchFromMode ? prefs->memLimit : DICTSIZE_MAX;
#  772|->         if (fileSize >  dictSizeMax) {
#  773|               EXM_THROW(34, "Dictionary file %s is too large (> %u bytes)",
#  774|                               fileName,  (unsigned)dictSizeMax);   /* avoid extreme cases */

Error: GCC_ANALYZER_WARNING (CWE-415): [#def35]
zstd-1.5.7/programs/util.c:103:5: warning[-Wanalyzer-double-free]: double-‘free’ of ‘ptr’
zstd-1.5.7/programs/util.c:1293:1: enter_function: entry to ‘UTIL_createExpandedFNT’
zstd-1.5.7/programs/util.c:1296:24: acquire_memory: allocated here
zstd-1.5.7/programs/util.c:1299:8: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/util.c:1302:23: branch_false: ...to here
zstd-1.5.7/programs/util.c:1302:41: branch_true: following ‘true’ branch (when ‘ifnNb < nbIfns’)...
zstd-1.5.7/programs/util.c:1303:45: branch_true: ...to here
zstd-1.5.7/programs/util.c:1303:18: call_function: calling ‘UTIL_isDirectory’ from ‘UTIL_createExpandedFNT’
zstd-1.5.7/programs/util.c:1303:18: return_function: returning to ‘UTIL_createExpandedFNT’ from ‘UTIL_isDirectory’
zstd-1.5.7/programs/util.c:1303:16: branch_false: following ‘false’ branch...
zstd-1.5.7/programs/util.c:1318:38: branch_false: ...to here
zstd-1.5.7/programs/util.c:1318:38: call_function: calling ‘UTIL_prepareFileList’ from ‘UTIL_createExpandedFNT’
#  101|       void *newptr = realloc(ptr, size);
#  102|       if (newptr) return newptr;
#  103|->     free(ptr);
#  104|       return NULL;
#  105|   }

Error: CPPCHECK_WARNING (CWE-682): [#def36]
zstd-1.5.7/programs/util.c:1297: error[nullPointerArithmeticOutOfMemory]: If memory allocation fail: pointer addition with NULL pointer.
# 1295|       unsigned nbFiles;
# 1296|       char* buf = (char*)malloc(LIST_SIZE_INCREASE);
# 1297|->     char* bufend = buf + LIST_SIZE_INCREASE;
# 1298|   
# 1299|       if (!buf) return NULL;

Scan Properties

analyzer-version-clippy1.86.0
analyzer-version-cppcheck2.17.1
analyzer-version-gcc15.0.1
analyzer-version-gcc-analyzer15.0.1
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-68.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250425.124705.g1c7c448.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-namezstd-1.5.7-1.fc43
store-results-to/tmp/tmp_gvreez7/zstd-1.5.7-1.fc43.tar.xz
time-created2025-04-25 16:12:05
time-finished2025-04-25 16:15:46
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'unicontrol,cppcheck,gcc,clippy,shellcheck' '-o' '/tmp/tmp_gvreez7/zstd-1.5.7-1.fc43.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmp_gvreez7/zstd-1.5.7-1.fc43.src.rpm'
tool-versioncsmock-3.8.1.20250422.172604.g26bc3d6-1.el9