Fixed CBotClass::FreeLock crash on some compilers
parent
9bece23ede
commit
84521ef08a
|
@ -148,7 +148,12 @@ void CBotClass::FreeLock(CBotProgram* prog)
|
||||||
pClass->m_lockCurrentCount = 0;
|
pClass->m_lockCurrentCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pClass->m_lockProg.erase(std::remove(pClass->m_lockProg.begin(), pClass->m_lockProg.end(), prog));
|
// Note: erasing an end iterator is undefined behaviour
|
||||||
|
auto it = std::remove(pClass->m_lockProg.begin(), pClass->m_lockProg.end(), prog);
|
||||||
|
if (it != pClass->m_lockProg.end())
|
||||||
|
{
|
||||||
|
pClass->m_lockProg.erase(it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ private:
|
||||||
|
|
||||||
//! How many times the program currently holding the lock called Lock()
|
//! How many times the program currently holding the lock called Lock()
|
||||||
int m_lockCurrentCount = 0;
|
int m_lockCurrentCount = 0;
|
||||||
//! Programs waiting for lock
|
//! Programs waiting for lock. m_lockProg[0] is the program currently holding the lock, if any
|
||||||
std::deque<CBotProgram*> m_lockProg{};
|
std::deque<CBotProgram*> m_lockProg{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue