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

Unified Diff: src/d8.cc

Issue 7867036: d8 external array c'tors: allow parameters that can be converted to numbers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: add test Created 9 years, 3 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 | test/mjsunit/external-array.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 01b4939902e1b0373997dbbab460c427dd35e69a..9390c846d60055aef88431c04c70761dcfb00aac 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -295,8 +295,12 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
size_t length = 0;
if (args[0]->IsUint32()) {
length = args[0]->Uint32Value();
- } else if (args[0]->IsNumber()) {
- double raw_length = args[0]->NumberValue();
+ } else {
+ Local<Number> number = args[0]->ToNumber();
+ if (number.IsEmpty() || !number->IsNumber()) {
+ return ThrowException(String::New("Array length must be a number."));
+ }
+ double raw_length = number->NumberValue();
if (raw_length < 0) {
return ThrowException(String::New("Array length must not be negative."));
}
@@ -305,8 +309,6 @@ Handle<Value> Shell::CreateExternalArray(const Arguments& args,
String::New("Array length exceeds maximum length."));
}
length = static_cast<size_t>(raw_length);
- } else {
- return ThrowException(String::New("Array length must be a number."));
}
if (length > static_cast<size_t>(kMaxLength)) {
return ThrowException(String::New("Array length exceeds maximum length."));
« no previous file with comments | « no previous file | test/mjsunit/external-array.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698