diff options
author | Yves Orton <demerphq@gmail.com> | 2023-01-13 18:23:01 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2023-01-13 20:24:28 +0100 |
commit | 61e2c0af14d6f848fd8f2ca85beeeb8363365321 (patch) | |
tree | fd216903af873a9ca48385ce53cb413d58ec10a4 /regexec.c | |
parent | 1b3de34b7cfc0bdda5cfe9dbb2690bf5b8faeed1 (diff) | |
download | perl-61e2c0af14d6f848fd8f2ca85beeeb8363365321.tar.gz |
regexec.c - avoid calling regrepeat when the max is 0
When we have a max quantifier of 0, then the quantified
item is essentially a NOTHING reop. Regardless, we do not
need to call regrepeat, and doing so confuses some of the
logic it contains. Simply avoiding calling regrepeat()
fixes the underlying issue, and avoids the broken code.
This fixes GH Issue #20690.
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -9316,7 +9316,10 @@ NULL /* avoid taking address of locinput, so it can remain * a register var */ char *li = locinput; - ST.count = regrepeat(rex, &li, ST.A, loceol, reginfo, ST.max); + if (ST.max) + ST.count = regrepeat(rex, &li, ST.A, loceol, reginfo, ST.max); + else + ST.count = 0; if (ST.count < ST.min) sayNO; SET_locinput(li); @@ -10058,6 +10061,8 @@ S_regrepeat(pTHX_ regexp *prog, char **startposp, const regnode *p, unsigned int to_complement = 0; /* Invert the result? */ char_class_number_ classnum; + assert(max); + PERL_ARGS_ASSERT_REGREPEAT; /* This routine is structured so that we switch on the input OP. Each OP |