[programs] Fix infinite loop when empty input is passed to trainer

When an empty input file was passed to the dictionary trainer, it would infinite loop.
The added test case exposes the bug, and is fixed with this PR.
This commit is contained in:
Nick Terrell
2022-03-02 11:05:26 -08:00
parent 87406b5f3b
commit da737c7ab8
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)