Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: src/value-serializer.cc

Issue 2665313003: ValueSerializer: Check for zero length before casting to FixedDoubleArray. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/value-serializer.h" 5 #include "src/value-serializer.h"
6 6
7 #include <type_traits> 7 #include <type_traits>
8 8
9 #include "src/base/logging.h" 9 #include "src/base/logging.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // Fast paths. Note that FAST_ELEMENTS in particular can bail due to the 547 // Fast paths. Note that FAST_ELEMENTS in particular can bail due to the
548 // structure of the elements changing. 548 // structure of the elements changing.
549 switch (array->GetElementsKind()) { 549 switch (array->GetElementsKind()) {
550 case FAST_SMI_ELEMENTS: { 550 case FAST_SMI_ELEMENTS: {
551 Handle<FixedArray> elements(FixedArray::cast(array->elements()), 551 Handle<FixedArray> elements(FixedArray::cast(array->elements()),
552 isolate_); 552 isolate_);
553 for (; i < length; i++) WriteSmi(Smi::cast(elements->get(i))); 553 for (; i < length; i++) WriteSmi(Smi::cast(elements->get(i)));
554 break; 554 break;
555 } 555 }
556 case FAST_DOUBLE_ELEMENTS: { 556 case FAST_DOUBLE_ELEMENTS: {
557 // Elements are empty_fixed_array, not a FixedDoubleArray, if the array
558 // is empty. No elements to encode in this case anyhow.
559 if (length == 0) break;
557 Handle<FixedDoubleArray> elements( 560 Handle<FixedDoubleArray> elements(
558 FixedDoubleArray::cast(array->elements()), isolate_); 561 FixedDoubleArray::cast(array->elements()), isolate_);
559 for (; i < length; i++) { 562 for (; i < length; i++) {
560 WriteTag(SerializationTag::kDouble); 563 WriteTag(SerializationTag::kDouble);
561 WriteDouble(elements->get_scalar(i)); 564 WriteDouble(elements->get_scalar(i));
562 } 565 }
563 break; 566 break;
564 } 567 }
565 case FAST_ELEMENTS: { 568 case FAST_ELEMENTS: {
566 Handle<Object> old_length(array->length(), isolate_); 569 Handle<Object> old_length(array->length(), isolate_);
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 if (stack.size() != 1) { 1937 if (stack.size() != 1) {
1935 isolate_->Throw(*isolate_->factory()->NewError( 1938 isolate_->Throw(*isolate_->factory()->NewError(
1936 MessageTemplate::kDataCloneDeserializationError)); 1939 MessageTemplate::kDataCloneDeserializationError));
1937 return MaybeHandle<Object>(); 1940 return MaybeHandle<Object>();
1938 } 1941 }
1939 return scope.CloseAndEscape(stack[0]); 1942 return scope.CloseAndEscape(stack[0]);
1940 } 1943 }
1941 1944
1942 } // namespace internal 1945 } // namespace internal
1943 } // namespace v8 1946 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698