Fix unsigned integer bug in LocalVector::erase

`erase()` calls `find()` to get the index of the element to remove, if
any.

c2151e1813/core/local_vector.h (L77-L81)

`find()` returns a signed integer. In particular, it returns -1 if
no element is found. Since `erase()` converts this to an unsigned type, the
wrong element may be erroneously removed from the vector.

Other ways to fix this would involve changing function signatures, so
this seemed to be the least disruptive change.

Fixes #38884
This commit is contained in:
Maganty Rushyendra 2020-05-27 21:39:51 +08:00
parent 2aa46ee4ae
commit 4ef246f804

View file

@ -75,7 +75,7 @@ public:
}
void erase(const T &p_val) {
U idx = find(p_val);
int64_t idx = find(p_val);
if (idx >= 0) {
remove(idx);
}