Blob Blame History Raw
From 9ddce66fd62671186bcd66b1aa72e31cba135c26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 9 Apr 2015 17:23:38 +0200
Subject: [PATCH] Fix mutual recursion inside other groups stack overflow bug.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Upstream commit ported to 8.36:

commit e97ec7dc839022a3efe740c532ea3e67e4446430
Author: ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>
Date:   Fri Mar 27 17:48:28 2015 +0000

    Fix mutual recursion inside other groups stack overflow bug.

    git-svn-id: svn://vcs.exim.org/pcre/code/trunk@1537 2f5784b3-3f2a-0410-8824-cb99058d5e15

Signed-off-by: Petr Písař <ppisar@redhat.com>

diff --git a/pcre_compile.c b/pcre_compile.c
index c256ea5..ce187cd 100644
--- a/pcre_compile.c
+++ b/pcre_compile.c
@@ -2469,8 +2469,8 @@ for (code = first_significant_code(code + PRIV(OP_lengths)[*code], TRUE);
       empty_branch = FALSE;
       do
         {
-        if (!empty_branch && could_be_empty_branch(code, endcode, utf, cd, NULL))
-          empty_branch = TRUE;
+        if (!empty_branch && could_be_empty_branch(code, endcode, utf, cd, 
+          recurses)) empty_branch = TRUE;
         code += GET(code, 1);
         }
       while (*code == OP_ALT);
diff --git a/testdata/testinput2 b/testdata/testinput2
index 015422e..c01a094 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -4084,4 +4084,6 @@ backtracking verbs. --/
 "(?(?=)?==)(((((((((?=)))))))))"
     a
 
+"((?2)+)((?1))"
+
 /-- End of testinput2 --/
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 9a1b14e..0118730 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -14216,4 +14216,6 @@ Failed: non-hex character in \x{} (closing brace missing?) at offset 3
     a
 No match
 
+"((?2)+)((?1))"
+
 /-- End of testinput2 --/
-- 
2.1.0