[vm/io] Range check Filter_Process arguments

Add a check both in the native implementation and on the Dart side (to
avoid throwing uncatchable ApiError).

Simplify native implementation: Dart_ListGetAsBytes has fast path for
byte sized typed data lists, so there is no reason to inline the 
same fast path into the caller.

Reported by Kyounghwan Kim (@drg2533)

TEST=runtime/tests/vm/dart/regress_b508627933_test.dart

Bug: b/508627933
Change-Id: I14c0f5270f143ed2386200241b13313f6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Slava Egorov
2026-05-07 04:18:06 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 0f9ce46c6d
commit d2903a568c
3 changed files with 54 additions and 37 deletions
+6 -1
View File
@@ -7,7 +7,12 @@ part of "common_patch.dart";
base class _FilterImpl extends NativeFieldWrapperClass1
implements RawZLibFilter {
@pragma("vm:external-name", "Filter_Process")
external void process(List<int> data, int start, int end);
external void _process(List<int> data, int start, int end);
void process(List<int> data, int start, int end) {
RangeError.checkValidRange(start, end, data.length);
_process(data, start, end);
}
@pragma("vm:external-name", "Filter_Processed")
external List<int>? processed({bool flush = true, bool end = false});