mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
HPL1: fix heap use after free
This commit is contained in:
parent
eab1cbd3cf
commit
d5762cd762
@ -27,6 +27,7 @@
|
||||
|
||||
#include "hpl1/penumbra-overture/TriggerHandler.h"
|
||||
|
||||
#include "hpl1/algorithms.h"
|
||||
#include "hpl1/penumbra-overture/GameEnemy.h"
|
||||
#include "hpl1/penumbra-overture/Init.h"
|
||||
#include "hpl1/penumbra-overture/MapHandler.h"
|
||||
@ -142,19 +143,15 @@ void cTriggerHandler::Update(float afTimeStep) {
|
||||
|
||||
//////////////////////////////////
|
||||
// Go through triggers and remove when timer is out.
|
||||
tGameTriggerMapIt TriggerIt = m_mapTriggers.begin();
|
||||
for (; TriggerIt != m_mapTriggers.end();) {
|
||||
cGameTrigger *pTrigger = TriggerIt->second;
|
||||
|
||||
pTrigger->mfTimeCount -= afTimeStep;
|
||||
|
||||
if (pTrigger->mfTimeCount <= 0) {
|
||||
hplDelete(pTrigger);
|
||||
m_mapTriggers.erase(TriggerIt++);
|
||||
} else {
|
||||
++TriggerIt;
|
||||
auto const newEnd = Hpl1::removeIf(m_mapTriggers.begin(), m_mapTriggers.end(), [afTimeStep](tGameTriggerMap::value_type &pair) {
|
||||
pair.second->mfTimeCount -= afTimeStep;
|
||||
if (pair.second->mfTimeCount <= 0) {
|
||||
hplDelete(pair.second);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
m_mapTriggers.erase(newEnd, m_mapTriggers.end());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user