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

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

Issue 2395073003: ValueSerializer: Check for no matching ArrayBufferView type being found. (Closed)
Patch Set: and a unittest Created 4 years, 2 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 | test/unittests/value-serializer-unittest.cc » ('j') | 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 1392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 return data_view; 1403 return data_view;
1404 } 1404 }
1405 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1405 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
1406 case ArrayBufferViewTag::k##Type##Array: \ 1406 case ArrayBufferViewTag::k##Type##Array: \
1407 external_array_type = kExternal##Type##Array; \ 1407 external_array_type = kExternal##Type##Array; \
1408 element_size = size; \ 1408 element_size = size; \
1409 break; 1409 break;
1410 TYPED_ARRAYS(TYPED_ARRAY_CASE) 1410 TYPED_ARRAYS(TYPED_ARRAY_CASE)
1411 #undef TYPED_ARRAY_CASE 1411 #undef TYPED_ARRAY_CASE
1412 } 1412 }
1413 if (byte_offset % element_size != 0 || byte_length % element_size != 0) { 1413 if (element_size == 0 || byte_offset % element_size != 0 ||
1414 byte_length % element_size != 0) {
1414 return MaybeHandle<JSArrayBufferView>(); 1415 return MaybeHandle<JSArrayBufferView>();
1415 } 1416 }
1416 Handle<JSTypedArray> typed_array = isolate_->factory()->NewJSTypedArray( 1417 Handle<JSTypedArray> typed_array = isolate_->factory()->NewJSTypedArray(
1417 external_array_type, buffer, byte_offset, byte_length / element_size, 1418 external_array_type, buffer, byte_offset, byte_length / element_size,
1418 pretenure_); 1419 pretenure_);
1419 AddObjectWithID(id, typed_array); 1420 AddObjectWithID(id, typed_array);
1420 return typed_array; 1421 return typed_array;
1421 } 1422 }
1422 1423
1423 MaybeHandle<JSObject> ValueDeserializer::ReadHostObject() { 1424 MaybeHandle<JSObject> ValueDeserializer::ReadHostObject() {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 if (stack.size() != 1) { 1725 if (stack.size() != 1) {
1725 isolate_->Throw(*isolate_->factory()->NewError( 1726 isolate_->Throw(*isolate_->factory()->NewError(
1726 MessageTemplate::kDataCloneDeserializationError)); 1727 MessageTemplate::kDataCloneDeserializationError));
1727 return MaybeHandle<Object>(); 1728 return MaybeHandle<Object>();
1728 } 1729 }
1729 return scope.CloseAndEscape(stack[0]); 1730 return scope.CloseAndEscape(stack[0]);
1730 } 1731 }
1731 1732
1732 } // namespace internal 1733 } // namespace internal
1733 } // namespace v8 1734 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/value-serializer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698