1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix crash due to erase/remove typo

A race condition would result in trying to remove an element that didn't exist, and thus erasing end (undefined behavior) instead of erasing [end, end) (no-op)
This commit is contained in:
tux3 2015-10-07 18:12:54 +02:00
parent f45256baf1
commit 1db17ae1ec

View File

@ -15,7 +15,7 @@ public:
// Qt
inline bool isEmpty() { return v.empty(); }
bool contains(int i) { return std::find_if(begin(), end(), [i](T& t){return (int)t == i;}) != end(); }
void remove(int i) { v.erase(std::remove_if(begin(), end(), [i](T& t){return (int)t == i;})); }
void remove(int i) { v.erase(std::remove_if(begin(), end(), [i](T& t){return (int)t == i;}), end()); }
T& operator[](int i)
{
iterator it = std::find_if(begin(), end(), [i](T& t){return (int)t == i;});