فهرست منبع

don't allow setting a key or value on -1 index

AzaezelX 1 سال پیش
والد
کامیت
36c1e928ca
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      Engine/source/console/arrayObject.cpp

+ 2 - 2
Engine/source/console/arrayObject.cpp

@@ -450,7 +450,7 @@ void ArrayObject::append(ArrayObject* obj)
 
 
 void ArrayObject::setKey( const String &key, S32 index )
 void ArrayObject::setKey( const String &key, S32 index )
 {
 {
-   if ( index >= mArray.size() )
+   if (index >= mArray.size() || index < 0)
       return;
       return;
 
 
    mArray[index].key = key;
    mArray[index].key = key;
@@ -460,7 +460,7 @@ void ArrayObject::setKey( const String &key, S32 index )
 
 
 void ArrayObject::setValue( const String &value, S32 index )
 void ArrayObject::setValue( const String &value, S32 index )
 {
 {
-   if ( index >= mArray.size() )
+   if (index >= mArray.size() || index < 0)
       return;
       return;
    
    
    mArray[index].value = value;
    mArray[index].value = value;