Merge pull request #189 from tevador/pr-set-cache

Fix potential use-after-free when reallocating cache
fix-crash
tevador 4 years ago committed by GitHub
commit 6a4afc721f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}

@ -54,6 +54,9 @@ public:
{
return program;
}
const uint8_t* getMemory() const {
return mem.memory;
}
protected:
void initialize();
alignas(64) randomx::Program program;

Loading…
Cancel
Save