fix potential use-after-free when reallocating cache

This commit is contained in:
tevador
2020-06-27 20:21:06 +02:00
parent 7741eb1e97
commit 32ab5dea54
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -329,7 +329,7 @@ extern "C" {
void randomx_vm_set_cache(randomx_vm *machine, randomx_cache* cache) {
assert(machine != nullptr);
assert(cache != nullptr && cache->isInitialized());
if (machine->cacheKey != cache->cacheKey) {
if (machine->cacheKey != cache->cacheKey || machine->getMemory() != cache->memory) {
machine->setCache(cache);
machine->cacheKey = cache->cacheKey;
}