Merge pull request #3081 from terrelln/dict-load-zero

[programs] Fix infinite loop when empty input is passed to trainer
This commit is contained in:
Nick Terrell
2022-03-02 12:58:51 -08:00
committed by GitHub
3 changed files with 14 additions and 1 deletions
+4 -1
View File
@@ -128,8 +128,11 @@ static int DiB_loadFiles(
while ( nbSamplesLoaded < sstSize && fileIndex < nbFiles ) {
size_t fileDataLoaded;
S64 const fileSize = DiB_getFileSize(fileNamesTable[fileIndex]);
if (fileSize <= 0) /* skip if zero-size or file error */
if (fileSize <= 0) {
/* skip if zero-size or file error */
++fileIndex;
continue;
}
f = fopen( fileNamesTable[fileIndex], "rb");
if (f == NULL)
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
set -e
for i in $(seq 50); do
datagen -s$i > file$i
done
touch empty
set -v
zstd -q --train empty file*
@@ -0,0 +1 @@
zstd -q --train empty file*