commit | 1b59349e6149413ed65f297f2ad1bd5ef24d97a9 | [log] [tgz] |
---|---|---|
author | Joshua Litt <joshualitt@google.com> | Mon Jan 09 21:13:14 2023 +0000 |
committer | Commit Queue <dart-scoped@luci-project-accounts.iam.gserviceaccount.com> | Mon Jan 09 21:13:14 2023 +0000 |
tree | c7f836df9b07b6881b5cd195b73e5a4063927aa4 | |
parent | 6ef8df0878c775dc5f6fb534f383b25707010304 [diff] |
[dart2wasm] Fix for RegExp error handling. Change-Id: I9bac9edc4ff35da069767c1576cded9e0b10813e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275784 Commit-Queue: Joshua Litt <joshualitt@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/sdk/lib/_internal/wasm/lib/regexp_helper.dart b/sdk/lib/_internal/wasm/lib/regexp_helper.dart index d87b498..03d2fa8 100644 --- a/sdk/lib/_internal/wasm/lib/regexp_helper.dart +++ b/sdk/lib/_internal/wasm/lib/regexp_helper.dart
@@ -175,7 +175,12 @@ int get end => (start + (_match[0].toString()).length); - String? group(int index) => _match[index]?.toString(); + String? group(int index) { + if (index < 0 || index >= _match.length) { + throw RangeError("Index $index is out of range ${_match.length}"); + } + return _match[index]?.toString(); + } String? operator [](int index) => group(index);