aboutsummaryrefslogtreecommitdiff
path: root/tests/regression_fuzz.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regression_fuzz.rs')
-rw-r--r--tests/regression_fuzz.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/regression_fuzz.rs b/tests/regression_fuzz.rs
index 5f92ed0..4e76704 100644
--- a/tests/regression_fuzz.rs
+++ b/tests/regression_fuzz.rs
@@ -17,3 +17,15 @@ fn fuzz1() {
fn empty_any_errors_no_panic() {
assert!(regex_new!(r"\P{any}").is_err());
}
+
+// This tests that a very large regex errors during compilation instead of
+// using gratuitous amounts of memory. The specific problem is that the
+// compiler wasn't accounting for the memory used by Unicode character classes
+// correctly.
+//
+// See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33579
+#[test]
+fn big_regex_fails_to_compile() {
+ let pat = "[\u{0}\u{e}\u{2}\\w~~>[l\t\u{0}]p?<]{971158}";
+ assert!(regex_new!(pat).is_err());
+}