1
0
Fork 0

DataBlockCache: Fix crash in cache invalidation (#142)

The original version uses a reverse iterator,
whose .base() is invalid after KillMacroBlock() erases it.
This commit is contained in:
scx 2019-09-23 01:19:56 +02:00 committed by Thomas Goyne
parent cb0af6ca35
commit 67d9fd9aa4
1 changed files with 5 additions and 2 deletions

View File

@ -150,8 +150,11 @@ public:
}
// Remove old entries until we're under the max size
for (auto it = age.rbegin(); size > max_size && it != age.rend(); )
KillMacroBlock(**it++);
while (size > max_size) {
// When size > 0, age should never be empty
assert(!age.empty());
KillMacroBlock(**age.rbegin());
}
}
/// @brief Obtain a data block from the cache