diff --git a/engines/grim/pool.h b/engines/grim/pool.h index 1d19e82faea..72d10f68922 100644 --- a/engines/grim/pool.h +++ b/engines/grim/pool.h @@ -314,9 +314,10 @@ void PoolObject::Pool::restoreObjects(SaveGame *state) { Common::HashMap tempMap; for (int32 i = 0; i < size; ++i) { int32 id = state->readLESint32(); - T *t = _map.getVal(id); - _map.erase(id); - if (!t) { + T *t = nullptr; + if (_map.tryGetVal(id, t)) + _map.erase(id); + else { t = new T(); t->setId(id); }