Merge pull request #4487 from neiljohari/adhoc/dictionary-file-counting

make DiB_fileStats skip invalid files (fileSize <= 0) to prevent negative totals and bogus allocation
This commit is contained in:
Yann Collet
2025-09-19 21:42:06 -08:00
committed by GitHub
+9 -2
View File
@@ -280,8 +280,15 @@ static fileStats DiB_fileStats(const char** fileNamesTable, int nbFiles, size_t
for (n=0; n<nbFiles; n++) {
S64 const fileSize = DiB_getFileSize(fileNamesTable[n]);
/* TODO: is there a minimum sample size? What if the file is 1-byte? */
if (fileSize == 0) {
DISPLAYLEVEL(3, "Sample file '%s' has zero size, skipping...\n", fileNamesTable[n]);
/* Skip empty or invalid files */
if (fileSize <= 0) {
if (fileSize < 0) {
DISPLAYLEVEL(3, "Sample file '%s' is unreadable or stat failed, skipping...\n",
fileNamesTable[n]);
} else {
DISPLAYLEVEL(3, "Sample file '%s' has zero size, skipping...\n",
fileNamesTable[n]);
}
continue;
}