Fix PoolVector resize and subarray.
The first used to accept negative values, the second would crash if out of bound.
This commit is contained in:
parent
05a0a68c72
commit
679bb882fc
1 changed files with 4 additions and 2 deletions
|
@ -411,8 +411,8 @@ public:
|
||||||
p_to = size() + p_to;
|
p_to = size() + p_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
CRASH_BAD_INDEX(p_from, size());
|
ERR_FAIL_INDEX_V(p_from, size(), PoolVector<T>());
|
||||||
CRASH_BAD_INDEX(p_to, size());
|
ERR_FAIL_INDEX_V(p_to, size(), PoolVector<T>());
|
||||||
|
|
||||||
PoolVector<T> slice;
|
PoolVector<T> slice;
|
||||||
int span = 1 + p_to - p_from;
|
int span = 1 + p_to - p_from;
|
||||||
|
@ -511,6 +511,8 @@ const T PoolVector<T>::operator[](int p_index) const {
|
||||||
template <class T>
|
template <class T>
|
||||||
Error PoolVector<T>::resize(int p_size) {
|
Error PoolVector<T>::resize(int p_size) {
|
||||||
|
|
||||||
|
ERR_FAIL_COND_V(p_size < 0, ERR_INVALID_PARAMETER);
|
||||||
|
|
||||||
if (alloc == NULL) {
|
if (alloc == NULL) {
|
||||||
|
|
||||||
if (p_size == 0)
|
if (p_size == 0)
|
||||||
|
|
Loading…
Reference in a new issue