| Index: src/runtime.cc
|
| diff --git a/src/runtime.cc b/src/runtime.cc
|
| index b8d9737cd17bbb6c0ba8de676f9566bdd920eda3..fe023f9e6647734b94d800bc4550e37c70c91390 100644
|
| --- a/src/runtime.cc
|
| +++ b/src/runtime.cc
|
| @@ -908,6 +908,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
|
| ASSERT(byte_length % element_size == 0);
|
| size_t length = byte_length / element_size;
|
|
|
| + if (length > static_cast<unsigned>(Smi::kMaxValue)) {
|
| + return isolate->Throw(*isolate->factory()->
|
| + NewRangeError("invalid_typed_array_length",
|
| + HandleVector<Object>(NULL, 0)));
|
| + }
|
| +
|
| Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
|
| holder->set_length(*length_obj);
|
| holder->set_weak_next(buffer->weak_first_view());
|
| @@ -947,9 +953,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) {
|
|
|
| Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
|
| size_t length = NumberToSize(isolate, *length_obj);
|
| - if (length > (kMaxInt / element_size)) {
|
| +
|
| + if ((length > static_cast<unsigned>(Smi::kMaxValue)) ||
|
| + (length > (kMaxInt / element_size))) {
|
| return isolate->Throw(*isolate->factory()->
|
| - NewRangeError("invalid_array_buffer_length",
|
| + NewRangeError("invalid_typed_array_length",
|
| HandleVector<Object>(NULL, 0)));
|
| }
|
| size_t byte_length = length * element_size;
|
| @@ -14724,6 +14732,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalArrayConstructor) {
|
| }
|
|
|
|
|
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) {
|
| + return Smi::FromInt(Smi::kMaxValue);
|
| +}
|
| +
|
| +
|
| // ----------------------------------------------------------------------------
|
| // Implementation of Runtime
|
|
|
|
|