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

Unified Diff: sdk/lib/typed_data/dart2js/typed_data_dart2js.dart

Issue 19965003: Fix sublist check, add missing methods and add tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 | « runtime/lib/typed_data.dart ('k') | tests/lib/typed_data/typed_data_list_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/typed_data/dart2js/typed_data_dart2js.dart
diff --git a/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart b/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart
index 2b6bb8ec4272fa6df9855c3d800ddfef59d3e99f..9190f3649182e9125e0b74f8aee82e7df485a38c 100644
--- a/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart
+++ b/sdk/lib/typed_data/dart2js/typed_data_dart2js.dart
@@ -61,10 +61,14 @@ class TypedData native "ArrayBufferView" {
}
int _checkSublistArguments(int start, int end, int length) {
- _checkIndex(start, length);
+ // For `sublist` the [start] and [end] indices are allowed to be equal to
+ // [length]. However, [_checkIndex] only allows incides in the range
+ // 0 .. length - 1. We therefore increment the [length] argument by one
+ // for the [_checkIndex] checks.
+ _checkIndex(start, length + 1);
if (end == null) return length;
- _checkIndex(end, length);
- if (start > end) throw new RangeError.value(end);
+ _checkIndex(end, length + 1);
+ if (start > end) throw new RangeError.range(start, 0, end);
return end;
}
}
« no previous file with comments | « runtime/lib/typed_data.dart ('k') | tests/lib/typed_data/typed_data_list_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698