diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 08e42a7b4d..5729f5c92c 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -538,11 +538,12 @@ bool CachingFileLoader::MakeCacheSpaceFor(size_t blocks, bool readingAhead) { for (auto it = blocks_.begin(); it != blocks_.end(); ) { // Check for the minimum seen generation. // TODO: Do this smarter? - if (it->second.generation < minGeneration) { + if (it->second.generation != 0 && it->second.generation < minGeneration) { minGeneration = it->second.generation; } - if (it->second.generation == oldestGeneration_) { + // 0 means it was never used yet or was the first read (e.g. block descriptor.) + if (it->second.generation == oldestGeneration_ || it->second.generation == 0) { s64 pos = it->first; delete it->second.ptr; blocks_.erase(it);