Fix a potential crash (exposed in war1gus orc lvl 6) that could leave CPlayer->FreeWorkers in an invalid state
This commit is contained in:
parent
a2ef204b23
commit
255195c499
1 changed files with 6 additions and 0 deletions
|
@ -812,6 +812,12 @@ void CPlayer::RemoveUnit(CUnit &unit)
|
|||
void CPlayer::UpdateFreeWorkers()
|
||||
{
|
||||
FreeWorkers.clear();
|
||||
if (FreeWorkers.capacity() != 0) {
|
||||
// Just calling FreeWorkers.clear() is not always appropriate.
|
||||
// Certain paths may leave FreeWorkers in an invalid state, so
|
||||
// it's safer to re-initialize.
|
||||
std::vector<CUnit*>().swap(FreeWorkers);
|
||||
}
|
||||
const int nunits = this->GetUnitCount();
|
||||
|
||||
for (int i = 0; i < nunits; ++i) {
|
||||
|
|
Loading…
Reference in a new issue