Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,30 @@ Mission *Campaign::getNextMission( Mission *current)
name = m_firstMission;
}
else
{
// Validate that current still points to a valid mission in our list
// to prevent use-after-free crashes
Bool foundCurrent = FALSE;
MissionListIt validateIt = m_missions.begin();
while(validateIt != m_missions.end())
{
if(*validateIt == current)
{
foundCurrent = TRUE;
break;
}
++validateIt;
}

// If current mission is not in our list anymore, it may have been freed
if(!foundCurrent)
{
DEBUG_LOG(("Campaign::getNextMission - current mission pointer is not in mission list, possible use-after-free"));
return NULL;
}

name = current->m_nextMission;
}
name.toLower();
MissionListIt it;
it = m_missions.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,30 @@ Mission *Campaign::getNextMission( Mission *current)
name = m_firstMission;
}
else
{
// Validate that current still points to a valid mission in our list
// to prevent use-after-free crashes
Bool foundCurrent = FALSE;
MissionListIt validateIt = m_missions.begin();
while(validateIt != m_missions.end())
{
if(*validateIt == current)
{
foundCurrent = TRUE;
break;
}
++validateIt;
}

// If current mission is not in our list anymore, it may have been freed
if(!foundCurrent)
{
DEBUG_LOG(("Campaign::getNextMission - current mission pointer is not in mission list, possible use-after-free"));
return NULL;
}

name = current->m_nextMission;
}
name.toLower();
MissionListIt it;
it = m_missions.begin();
Expand Down
Loading