From 4ef246f804c6662dcb9773447db85feb51006621 Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Wed, 27 May 2020 21:39:51 +0800 Subject: 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 --- core/local_vector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core') 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); } -- cgit v1.2.3