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

Unified Diff: runtime/lib/typed_data.cc

Issue 16347017: Fix exception type to ArgumentError instead of out of memory when checking the length argment of ty… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | no next file » | 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 23830)
+++ runtime/lib/typed_data.cc (working copy)
@@ -42,18 +42,12 @@
// Checks to see if a length will not result in an OOM error.
static void LengthCheck(intptr_t len, intptr_t max) {
- if (len > max) {
+ if (len < 0 || len > max) {
const String& error = String::Handle(String::NewFormatted(
- "insufficient memory to allocate a TypedData object of length (%"Pd")",
- len));
+ "Length (%"Pd") of TypedData object must be in range [0..%"Pd"]",
+ len, max));
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));
hausner 2013/06/11 20:20:14 Should the message include the word TypedData or w
siva 2013/06/11 20:33:39 It should be clear based on the stack trace. Dropp
- 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 | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698