Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

regcomp: OPFAIL is neither SIMPLE nor HASWIDTH #22095

Closed mauke closed 1 month ago

mauke commented 1 month ago

This is an extension of fc7dfe8e82a76ba43c, which marked zero-width constructs as non-SIMPLE.

This change affects synthetic OPFAIL nodes generated by the regclass optimizer (empty character classes like [^\W\S] should always fail to match), but which were still marked SIMPLE (indicating they match exactly one character). If such a character class is under a quantifier, it would cause regrepeat() to panic at runtime.

Fixes #22094.

hvds commented 1 month ago

I don't have time right now to check what other knock-on effects this might have, but LGTM in principle.

demerphq commented 1 month ago

Looks good to me.

demerphq commented 1 month ago

thank you @mauke, merged.