filesystem: dir: fix dir entry cache init in case of directory was empty previously

This commit is contained in:
Alibek Omarov 2023-01-03 00:24:57 +03:00
parent e621c98602
commit 42a3c7b059

View File

@ -210,6 +210,7 @@ static void FS_MergeDirEntries( dir_t *dir, const stringlist_t *list )
}
// now we can free old tree and replace it with temporary
// do not add null check there! If we hit it, it's probably a logic error!
Mem_Free( dir->entries );
dir->numentries = temp.numentries;
dir->entries = temp.entries;
@ -229,7 +230,7 @@ static int FS_MaybeUpdateDirEntries( dir_t *dir, const char *path, const char *e
dir->numentries = DIRENTRY_EMPTY_DIRECTORY;
ret = -1;
}
else if( dir->numentries < 0 ) // not initialized or was empty
else if( dir->numentries <= DIRENTRY_EMPTY_DIRECTORY ) // not initialized or was empty
{
FS_InitDirEntries( dir, &list );
ret = FS_FindDirEntry( dir, entryname );