summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-06-24 09:22:15 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-06-24 09:24:09 +0200
commit679bb882fc0f58df7fa002aa180b2ac574366af8 (patch)
treeb43f05e2b372c74658f00f967852f4706532229f
parent05a0a68c72cc16c443301398ab93e8d838401ac0 (diff)
Fix PoolVector resize and subarray.
The first used to accept negative values, the second would crash if out of bound.
-rw-r--r--core/pool_vector.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/core/pool_vector.h b/core/pool_vector.h
index 102a620f17..338de966f6 100644
--- a/core/pool_vector.h
+++ b/core/pool_vector.h
@@ -411,8 +411,8 @@ public:
p_to = size() + p_to;
}
- CRASH_BAD_INDEX(p_from, size());
- CRASH_BAD_INDEX(p_to, size());
+ ERR_FAIL_INDEX_V(p_from, size(), PoolVector<T>());
+ ERR_FAIL_INDEX_V(p_to, size(), PoolVector<T>());
PoolVector<T> slice;
int span = 1 + p_to - p_from;
@@ -511,6 +511,8 @@ const T PoolVector<T>::operator[](int p_index) const {
template <class T>
Error PoolVector<T>::resize(int p_size) {
+ ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
+
if (alloc == NULL) {
if (p_size == 0)