Added check for element in Get/SetEntProp funcs >= 0 (bug 5141, r=fyren).
authorNicholas Hastings <skamonkey@gmail.com>
Thu Oct 20 21:35:50 2011 -0400 (2011-10-20)
changeset 3417dc2562dfd57b
parent 3416 7cb415ecd933
child 3418 b0e93f5101ef
Added check for element in Get/SetEntProp funcs >= 0 (bug 5141, r=fyren).
core/smn_entities.cpp
     1.1 --- a/core/smn_entities.cpp	Mon Oct 17 11:02:42 2011 -0400
     1.2 +++ b/core/smn_entities.cpp	Thu Oct 20 21:35:50 2011 -0400
     1.3 @@ -968,7 +968,7 @@
     1.4  	}
     1.5  
     1.6  #define CHECK_SET_PROP_DATA_OFFSET() \
     1.7 -	if (element >= td->fieldSize) \
     1.8 +	if (element < 0 || element >= td->fieldSize) \
     1.9  	{ \
    1.10  		return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).", \
    1.11  			element, \
    1.12 @@ -1001,7 +1001,7 @@
    1.13  	{ \
    1.14  	case type: \
    1.15  		{ \
    1.16 -			if (element > 0) \
    1.17 +			if (element != 0) \
    1.18  			{ \
    1.19  				return pContext->ThrowNativeError("SendProp %s is not an array. Element %d is invalid.", \
    1.20  					prop, \
    1.21 @@ -1036,7 +1036,7 @@
    1.22  	} \
    1.23  	\
    1.24  	int elementCount = pTable->GetNumProps(); \
    1.25 -	if (element >= elementCount) \
    1.26 +	if (element < 0 || element >= elementCount) \
    1.27  	{ \
    1.28  		return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).", \
    1.29  			element, \
    1.30 @@ -1816,14 +1816,14 @@
    1.31  
    1.32  			bIsStringIndex = (td->fieldType != FIELD_CHARACTER);
    1.33  
    1.34 -			if (bIsStringIndex && element >= td->fieldSize)
    1.35 +			if (bIsStringIndex && (element < 0 || element >= td->fieldSize))
    1.36  			{
    1.37  				return pContext->ThrowNativeError("Element %d is out of bounds (Prop %s has %d elements).",
    1.38  					element,
    1.39  					prop,
    1.40  					td->fieldSize);
    1.41  			}
    1.42 -			else if (element > 1)
    1.43 +			else if (element != 0)
    1.44  			{
    1.45  				return pContext->ThrowNativeError("Prop %s is not an array. Element %d is invalid.",
    1.46  					prop,
    1.47 @@ -1864,7 +1864,7 @@
    1.48  					info.prop->GetType(),
    1.49  					DPT_String);
    1.50  			}
    1.51 -			else if (element > 0)
    1.52 +			else if (element != 0)
    1.53  			{
    1.54  				return pContext->ThrowNativeError("SendProp %s is not an array. Element %d is invalid.",
    1.55  					prop,