diff options
author | Maganty Rushyendra <mrushyendra@yahoo.com.sg> | 2020-05-27 21:39:51 +0800 |
---|---|---|
committer | Maganty Rushyendra <mrushyendra@yahoo.com.sg> | 2020-05-27 21:53:34 +0800 |
commit | 4ef246f804c6662dcb9773447db85feb51006621 (patch) | |
tree | ff529b4dafa0a53155b57552e310dc16e8427607 /core | |
parent | 2aa46ee4ae252b9cd13e6c8e4ace8a68ee14398b (diff) |
Fix unsigned integer bug in LocalVector::erase
`erase()` calls `find()` to get the index of the element to remove, if
any.
https://github.com/godotengine/godot/blob/c2151e18135817c9f926a5a00341016ac77301d4/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
Diffstat (limited to 'core')
-rw-r--r-- | core/local_vector.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/local_vector.h b/core/local_vector.h index b09a28b25a..7f96b25f8b 100644 --- a/core/local_vector.h +++ b/core/local_vector.h @@ -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); } |