Fix segfault with regular expressions that matched the zero-length string.

In regular expressions, repetition operators`{0,0}` and `{,0}` are valid, but they always match the zero-length string. For instance, `a{0,0}` and `[a-z]{0,0}` both match the zero-length string.

When the whole regular expression consists in one of these repetitions it caused a segfault during the evaluation of the regular expression because the `forward_code_ref` field for the root atom in the atom's tree was null.

Closes #2084.
This commit is contained in:
Victor M. Alvarez
2024-06-19 13:47:58 +02:00
parent 608fb3da46
commit 8616165472
3 changed files with 74 additions and 51 deletions
+2
View File
@@ -2517,6 +2517,8 @@ void test_re()
assert_true_regexp("a{0,1}?bc", "abc", "abc");
assert_true_regexp("a{0,1}bc", "bbc", "bc");
assert_true_regexp("a{0,1}?bc", "abc", "bc");
assert_true_regexp("a{,0}", "a", "");
assert_true_regexp("a{,0}", "x", "");
assert_true_regexp("aa{0,1}?bc", "abc", "abc");
assert_true_regexp("aa{0,1}?bc", "abc", "abc");
assert_true_regexp("aa{0,1}bc", "abc", "abc");