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

Unified Diff: src/runtime.cc

Issue 73943004: Limit the size for typed arrays to MaxSmi. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Typo Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.h ('k') | src/typedarray.js » ('j') | src/typedarray.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 2cf033c4ebbb9920a7fd3dbac12c52bc16baa7d4..af073ba72e8aa3c0c65b7f07ee3be8b14e3c5fac 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -917,6 +917,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_array_buffer_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());
@@ -935,7 +941,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) {
// If an array-like object happens to be a typed array of the same type,
// initializes backing store using memove.
//
-// Returns true if backing store was initialized or false otherwise.
+// Returns true if backing stor e was initialized or false otherwise.
Jakob Kummerow 2013/11/15 15:13:08 nit: accidental edit
Dmitry Lomov (no reviews) 2013/11/15 16:03:07 Done.
RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) {
HandleScope scope(isolate);
ASSERT(args.length() == 4);
@@ -956,7 +962,9 @@ 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",
HandleVector<Object>(NULL, 0)));
@@ -14813,6 +14821,11 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalArrayConstructor) {
}
+RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) {
+ return Smi::FromInt(Smi::kMaxValue);
+}
+
+
// ----------------------------------------------------------------------------
// Implementation of Runtime
« no previous file with comments | « src/runtime.h ('k') | src/typedarray.js » ('j') | src/typedarray.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698