From 1cc521808f1426426f7d6592642daa54bb77f900 Mon Sep 17 00:00:00 2001 From: a/ Date: Mon, 21 Jun 2021 21:40:43 +0900 Subject: [PATCH] SAGA2: Fix double free --- engines/saga2/objects.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/engines/saga2/objects.cpp b/engines/saga2/objects.cpp index bff0abd795a..2a92794fd8d 100644 --- a/engines/saga2/objects.cpp +++ b/engines/saga2/objects.cpp @@ -1817,8 +1817,7 @@ bool GameObject::addTimer(TimerID id, int16 frameInterval) { assert((*it)->getObject() == this); if (newTimer->thisID() == (*it)->thisID()) { - timerList->_timers.remove(*it); - delete *it; + timerList->_timers.erase(it); break; } @@ -1840,7 +1839,7 @@ void GameObject::removeTimer(TimerID id) { if ((timerList = fetchTimerList(this)) != nullptr) { for (Common::List::iterator it = timerList->_timers.begin(); it != timerList->_timers.end(); ++it) { if ((*it)->thisID() == id) { - timerList->_timers.remove(*it); + timerList->_timers.erase(it); if (timerList->_timers.empty()) delete timerList;