In perl.git, the branch maint-5.18 has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/0ec7dc753859025ffc69eb02bf79a3f27f794ab1?hp=4b985f173ee39b73a9f3cf7828a2060f323a06ae>

- Log -----------------------------------------------------------------
commit 0ec7dc753859025ffc69eb02bf79a3f27f794ab1
Author: Karl Williamson <[email protected]>
Date:   Mon Jul 1 10:26:14 2013 -0600

    Fix regex seqfault 5.18 regression
    
    This segfault is a result of an optimization that can leave the
    compilation in an inconsistent state.
    
      /f{0}/
    
    doesn't match anything, and hence should be removable from the regex for
    all f.  However,
    
      qr{(?&foo){0}(?<foo>)}
    
    caused a segfault.  What was happening prior to this commit is that
    (?&foo) refers to a named capture group further along in the regex.
    The "{0}" caused the "(?&foo)" to be discarded prior to setting up the
    pointers between the two related subexpressions; a segfault follows.
    
    This commit removes the optimization, and should be suitable for a
    maintenance release.
    
    One might think that no one would be writing code like this, but this
    example was distilled from machine-generated code in Regexp::Grammars.
    
    Perhaps this optimization can be done, but the location I chose for
    checking it was during parsing, which turns out to be premature.  It
    would be better to do it in the optimization phase of regex compilation.
    Another option would be to retain it where it was, but for it to operate
    only on a limited set of nodes, such as EXACTish, which would have no
    unintended consequences.  But that is for looking at in the future; the
    important thing is to have a simple patch suitable for fixing this
    regression in a maintenance release.
    
    For the record, the code being reverted was mistakenly added by me in
    commit 3018b823898645e44b8c37c70ac5c6302b031381, and wasn't even
    mentioned in that commit message.  It should have had its own commit.
    
    Conflicts:
        regcomp.c
-----------------------------------------------------------------------

Summary of changes:
 regcomp.c           | 10 ----------
 t/re/pat_advanced.t |  8 ++++++++
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/regcomp.c b/regcomp.c
index aaa57d1..f0387c3 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -9654,16 +9654,6 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, 
U32 depth)
                 ret = reg_node(pRExC_state, OPFAIL);
                 return ret;
             }
-            else if (max == 0) {    /* replace {0} with a nothing node */
-                if (SIZE_ONLY) {
-                    RExC_size = PREVOPER(RExC_size) - regarglen[(U8)NOTHING];
-                }
-                else {
-                    RExC_emit = orig_emit;
-                }
-                ret = reg_node(pRExC_state, NOTHING);
-                return ret;
-            }
 
        do_curly:
            if ((flags&SIMPLE)) {
diff --git a/t/re/pat_advanced.t b/t/re/pat_advanced.t
index faa8859..48a37c2 100644
--- a/t/re/pat_advanced.t
+++ b/t/re/pat_advanced.t
@@ -2281,6 +2281,14 @@ EOP
                             "Overlapping ranges in user-defined properties");
     }
 
+    { # Regexp:Grammars was broken:
+  # 
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2013-06/msg01290.html
+        fresh_perl_like('use warnings; "abc" =~ qr{(?&foo){0}abc(?<foo>)}',
+                        'Quantifier unexpected on zero-length expression',
+                        "",
+                        'No segfault on qr{(?&foo){0}abc(?<foo>)}');
+    }
+
     # !!! NOTE that tests that aren't at all likely to crash perl should go
     # a ways above, above these last ones.
 

--
Perl5 Master Repository

Reply via email to