LibRegex: Check backreference index before looking it up

If a backref happens after it's cleared, the slot may be cleared
already.
This commit is contained in:
Ali Mohammad Pur 2025-04-06 01:56:18 +02:00 committed by Andreas Kling
commit 299b9ca572
Notes: github-actions[bot] 2025-04-06 18:22:15 +00:00
2 changed files with 5 additions and 0 deletions

View file

@ -741,6 +741,8 @@ TEST_CASE(ECMA262_match)
// Tests nested lookahead with alternation - verifies proper save/restore stack cleanup
{ "a(?=.(?=c)|b)b"sv, "ab"sv, true },
{ "(?=)(?=\\d)"sv, "smart"sv, false },
// Backrefs are cleared after lookaheads, the indices should be checked before lookup.
{ "(?!(b))\\1"sv, "a"sv, false },
};
for (auto& test : tests) {