Chromium Code Reviews| Index: runtime/lib/double.cc |
| diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc |
| index 83b23d2fcc829d79c804e9e681c1ca7aebfdb396..79fb9fd6c08bbe9b74200a29c283b7885d67edcd 100644 |
| --- a/runtime/lib/double.cc |
| +++ b/runtime/lib/double.cc |
| @@ -182,26 +182,25 @@ DEFINE_NATIVE_ENTRY(Double_toInt, 1) { |
| } |
| -DEFINE_NATIVE_ENTRY(Double_parse, 1) { |
| +DEFINE_NATIVE_ENTRY(Double_parse, 3) { |
| GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(Integer, startValue, arguments->NativeArgAt(1)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(Integer, endValue, arguments->NativeArgAt(2)); |
| + const intptr_t start = startValue.AsTruncatedUint32Value(); |
| + const intptr_t end = endValue.AsTruncatedUint32Value(); |
| const intptr_t len = value.Length(); |
| + // Indices should be inside the string, and 0 <= start < end <= len. |
| // The native function only accepts one-byte strings. The Dart side converts |
|
Vyacheslav Egorov (Google)
2014/07/01 11:36:18
This comment does not seem to be valid anymore.
Lasse Reichstein Nielsen
2014/07/01 11:54:18
Well spotted.
|
| // other types of strings to one-byte strings, if necessary. |
| - if ((!value.IsOneByteString() && !value.IsExternalOneByteString()) |
| - || (len == 0)) { |
| - return Object::null(); |
| - } |
| - |
| - double double_value; |
| - const char* cstr = value.ToCString(); |
| - ASSERT(cstr != NULL); |
| - if (CStringToDouble(cstr, len, &double_value)) { |
| - return Double::New(double_value); |
| - } else { |
| - return Object::null(); |
| + if (0 <= start && start < end && end <= len) { |
| + double double_value; |
| + if (String::ParseDouble(value, start, end, &double_value)) { |
| + return Double::New(double_value); |
| + } |
| } |
| + return Object::null(); |
| } |