Index: src/accessors.cc |
diff --git a/src/accessors.cc b/src/accessors.cc |
index d8df05e2a5964f963a1376fb85dc7445331bfa28..806c679f4bc82ef016777fb8c329ca2637489a49 100644 |
--- a/src/accessors.cc |
+++ b/src/accessors.cc |
@@ -102,6 +102,15 @@ Object* Accessors::FlattenNumber(Object* value) { |
MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) { |
Isolate* isolate = object->GetIsolate(); |
+ |
+ // This means one of the object's prototypes is a JSArray and the |
+ // object does not have a 'length' property. Calling SetProperty |
+ // causes an infinite loop. |
+ if (!object->IsJSArray()) { |
+ return object->SetLocalPropertyIgnoreAttributes( |
+ isolate->heap()->length_symbol(), value, NONE); |
+ } |
+ |
value = FlattenNumber(value); |
// Need to call methods that may trigger GC. |
@@ -117,20 +126,8 @@ MaybeObject* Accessors::ArraySetLength(JSObject* object, Object* value, void*) { |
Handle<Object> number_v = Execution::ToNumber(value_handle, &has_exception); |
if (has_exception) return Failure::Exception(); |
- // Restore raw pointers, |
- object = *object_handle; |
- value = *value_handle; |
- |
if (uint32_v->Number() == number_v->Number()) { |
- if (object->IsJSArray()) { |
- return JSArray::cast(object)->SetElementsLength(*uint32_v); |
- } else { |
- // This means one of the object's prototypes is a JSArray and |
- // the object does not have a 'length' property. |
- // Calling SetProperty causes an infinite loop. |
- return object->SetLocalPropertyIgnoreAttributes( |
- isolate->heap()->length_symbol(), value, NONE); |
- } |
+ return Handle<JSArray>::cast(object_handle)->SetElementsLength(*uint32_v); |
} |
return isolate->Throw( |
*isolate->factory()->NewRangeError("invalid_array_length", |