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

Unified Diff: lib/array.cc

Issue 10782016: Enforce length/size limits for variable size heap object in order to (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/byte_array.cc » ('j') | lib/byte_array.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/array.cc
===================================================================
--- lib/array.cc (revision 9641)
+++ lib/array.cc (working copy)
@@ -18,9 +18,13 @@
ASSERT(type_arguments.IsNull() ||
(type_arguments.IsInstantiated() && (type_arguments.Length() == 1)));
GET_NATIVE_ARGUMENT(Smi, length, arguments->At(1));
- if (length.Value() < 0) {
+ intptr_t len = length.Value();
+ if (len < 0 || len > Array::kMaxElements) {
+ const String& error = String::Handle(String::NewFormatted(
+ "length (%ld) must be in the range [0..%ld]",
+ len, Array::kMaxElements));
GrowableArray<const Object*> args;
- args.Add(&length);
+ args.Add(&error);
Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
}
const Array& new_array = Array::Handle(Array::New(length.Value()));
« no previous file with comments | « no previous file | lib/byte_array.cc » ('j') | lib/byte_array.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698