SAGA2: Fix double free

This commit is contained in:
a/ 2021-06-21 21:40:43 +09:00 committed by Eugene Sandulenko
parent ccc350d400
commit 1cc521808f
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -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<Timer *>::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;