perl/perl-5.26.1-fix-132017-OPFAIL-insert-needs-to-set-flags-to-0.patch

70 lines
2.3 KiB
Diff
Raw Normal View History

From af6344c9702b589162d8672ae24130231698acae Mon Sep 17 00:00:00 2001
From: Yves Orton <demerphq@gmail.com>
Date: Sun, 10 Sep 2017 10:59:05 +0200
Subject: [PATCH] fix #132017 - OPFAIL insert needs to set flags to 0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
why reginsert doesnt do this stuff I dont know.
Petr Písař: Ported to 5.26.1.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
regcomp.c | 6 +++++-
t/re/pat.t | 5 ++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/regcomp.c b/regcomp.c
index b2de7f0..1df3df8 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -11724,6 +11724,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
if (max < min) { /* If can't match, warn and optimize to fail
unconditionally */
reginsert(pRExC_state, OPFAIL, orig_emit, depth+1);
+ orig_emit->flags = 0;
if (PASS2) {
ckWARNreg(RExC_parse, "Quantifier {n,m} with n > m can't match");
NEXT_OFF(orig_emit)= regarglen[OPFAIL] + NODE_STEP_REGNODE;
@@ -19343,8 +19344,11 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_
/* add on the verb argument if there is one */
if ( ( k == VERB || OP(o) == ACCEPT || OP(o) == OPFAIL ) && o->flags) {
- Perl_sv_catpvf(aTHX_ sv, ":%" SVf,
+ if ( ARG(o) )
+ Perl_sv_catpvf(aTHX_ sv, ":%" SVf,
SVfARG((MUTABLE_SV(progi->data->data[ ARG( o ) ]))));
+ else
+ sv_catpvs(sv, ":NULL");
}
#else
PERL_UNUSED_CONTEXT;
diff --git a/t/re/pat.t b/t/re/pat.t
index 2510eab..dda2a5a 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -23,7 +23,7 @@ BEGIN {
skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader;
skip_all_without_unicode_tables();
-plan tests => 838; # Update this when adding/deleting tests.
+plan tests => 839; # Update this when adding/deleting tests.
run_tests() unless caller;
@@ -1921,6 +1921,9 @@ EOP
pos($text) = 3;
ok(scalar($text !~ m{(~*=[a-z]=)}g), "RT #131575");
}
+ {
+ fresh_perl_is('"AA" =~ m/AA{1,0}/','',{},"handle OPFAIL insert properly");
+ }
} # End of sub run_tests
--
2.13.6