From 679bb882fc0f58df7fa002aa180b2ac574366af8 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Mon, 24 Jun 2019 09:22:15 +0200 Subject: [PATCH] Fix PoolVector resize and subarray. The first used to accept negative values, the second would crash if out of bound. --- core/pool_vector.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/pool_vector.h b/core/pool_vector.h index 102a620f171..338de966f63 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()); + ERR_FAIL_INDEX_V(p_to, size(), PoolVector()); PoolVector slice; int span = 1 + p_to - p_from; @@ -511,6 +511,8 @@ const T PoolVector::operator[](int p_index) const { template Error PoolVector::resize(int p_size) { + ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER); + if (alloc == NULL) { if (p_size == 0)