Fix crash in cache invalidation

The original version uses a reverse iterator, whose .base() is invalid after KillMacroBlock() erases it.

Fix TypesettingTools/Aegisub#33
Fix Aegisub/Aegisub#142
This commit is contained in:
wangqr 2019-09-08 12:49:03 -04:00
parent ad02d39f44
commit 9e6b7e94c0

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.back());
}
}
/// @brief Obtain a data block from the cache