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

Unified Diff: runtime/lib/string_patch.dart

Issue 605213002: Change restrictions on start/end on String.fromCharCodes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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_patch.dart
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
index 76ad8ffd33ecf52499b3e99e3fda19fa19b98d88..d1bcc986aa395b9f01c5db56a124dfdb4fd085f7 100644
--- a/runtime/lib/string_patch.dart
+++ b/runtime/lib/string_patch.dart
@@ -57,7 +57,6 @@ class _StringBase {
static String createFromCharCodes(Iterable<int> charCodes,
int start, int end) {
if (charCodes == null) throw new ArgumentError(charCodes);
- if (start < 0) throw new RangeError.value(start);
// TODO(srdjan): Also skip copying of wide typed arrays.
final ccid = ClassID.getID(charCodes);
bool isOneByteString = false;
@@ -70,10 +69,15 @@ class _StringBase {
charCodes = new List.from(charCodes, growable: false);
Søren Gjesse 2014/09/26 11:43:00 If the iterable is long (maybe even infinite) then
}
}
- if ((end == null) || (end > charCodes.length)) {
- end = charCodes.length;
+ int codeCount = charCodes.length;
+ if (start < 0 || start > codeCount) {
+ throw new RangeError.range(start, 0, codeCount);
+ }
+ if (end == null) {
+ end = codeCount;
+ } else if (end < start || end > codeCount) {
+ throw new RangeError.range(end, start, codeCount);
}
- if (end <= start) return "";
final len = end - start;
if (!isOneByteString) {
for (int i = start; i < end; i++) {
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/js_lib/core_patch.dart » ('j') | sdk/lib/_internal/compiler/js_lib/core_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698