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

Unified Diff: runtime/lib/typed_data.cc

Issue 14383016: Move negative length checks from Dart into the native. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 | runtime/lib/typed_data.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/typed_data.cc
===================================================================
--- runtime/lib/typed_data.cc (revision 22079)
+++ runtime/lib/typed_data.cc (working copy)
@@ -42,7 +42,6 @@
// Checks to see if a length will not result in an OOM error.
static void LengthCheck(intptr_t len, intptr_t max) {
- ASSERT(len >= 0);
if (len > max) {
const String& error = String::Handle(String::NewFormatted(
"insufficient memory to allocate a TypedData object of length (%"Pd")",
@@ -50,6 +49,12 @@
const Array& args = Array::Handle(Array::New(1));
args.SetAt(0, error);
Exceptions::ThrowByType(Exceptions::kOutOfMemory, args);
+ } else if (len < 0) {
+ const String& error = String::Handle(String::NewFormatted(
+ "%"Pd" must be greater than 0", len));
+ const Array& args = Array::Handle(Array::New(1));
+ args.SetAt(0, error);
+ Exceptions::ThrowByType(Exceptions::kArgument, args);
}
}
« no previous file with comments | « no previous file | runtime/lib/typed_data.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698