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

Unified Diff: runtime/lib/string.cc

Issue 1318943005: Update range errors to agree on the numbers. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: More tests Created 5 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
Index: runtime/lib/string.cc
diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc
index 9d4137ddea7b33b8e744364a25c29b4883b8d0d0..2eae245fa67c64d4fb35cd6812e0331d766daee6 100644
--- a/runtime/lib/string.cc
+++ b/runtime/lib/string.cc
@@ -515,7 +515,7 @@ static uint16_t StringValueAt(const String& str, const Integer& index) {
}
// An index larger than Smi is always illegal.
- Exceptions::ThrowRangeError("index", index, 0, str.Length());
+ Exceptions::ThrowRangeError("index", index, 0, str.Length() - 1);
return 0;
}
@@ -601,7 +601,7 @@ DEFINE_NATIVE_ENTRY(StringBuffer_createStringFromUint16Array, 3) {
intptr_t array_length = codeUnits.Length();
intptr_t length_value = length.Value();
if (length_value < 0 || length_value > array_length) {
- Exceptions::ThrowRangeError("length", length, 0, array_length + 1);
+ Exceptions::ThrowRangeError("length", length, 0, array_length);
}
const String& result = isLatin1.value()
? String::Handle(OneByteString::New(length_value, Heap::kNew))

Powered by Google App Engine
This is Rietveld 408576698