diff --git a/src/RJSArray.cpp b/src/RJSArray.cpp index c66c4333..7d74e598 100644 --- a/src/RJSArray.cpp +++ b/src/RJSArray.cpp @@ -173,9 +173,7 @@ JSValueRef ArraySplice(JSContextRef ctx, JSObjectRef function, JSObjectRef thisO } long remove = std::max(RJSValidatedValueToNumber(ctx, arguments[1]), 0); - if (index + remove > size) { - remove = size - index; - } + remove = std::min(remove, size - index); std::vector removedObjects(remove); for (size_t i = 0; i < remove; i++) {