]> granicus.if.org Git - php/commitdiff
Fixed bug #70868 (PCRE JIT and pattern reuse segfault)
authorXinchen Hui <laruence@gmail.com>
Fri, 6 Nov 2015 03:37:17 +0000 (11:37 +0800)
committerXinchen Hui <laruence@gmail.com>
Fri, 6 Nov 2015 03:37:17 +0000 (11:37 +0800)
NEWS
ext/spl/spl_iterators.c
ext/spl/tests/bug70868.phpt [moved from Zend/tests/bug70868.phpt with 100% similarity]

diff --git a/NEWS b/NEWS
index b19123201ad402c580c21763efd910e493cdc91b..0985ae6dda4ba244fd2a593807ac8538dbaccd41 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,7 @@ PHP                                                                        NEWS
     test suite). (Anatol)
 
 - SPL:
+  . Fixed bug #70868 (PCRE JIT and pattern reuse segfault). (Laruence)
   . Fixed bug #70853 (SplFixedArray throws exception when using ref variable
     as index). (Laruence)
 
index cd0c624b508b3d5d6de95d3da72bfaf4fd9a2660..b29fc5298bc25861e43c1244266417a57134d954 100644 (file)
@@ -2059,6 +2059,11 @@ SPL_METHOD(RegexIterator, accept)
        {
                case REGIT_MODE_MAX: /* won't happen but makes compiler happy */
                case REGIT_MODE_MATCH:
+#ifdef PCRE_EXTRA_MARK
+                       if (intern->u.regex.pce->extra) {
+                               intern->u.regex.pce->extra->flags &= ~PCRE_EXTRA_MARK;
+                       }
+#endif
                        count = pcre_exec(intern->u.regex.pce->re, intern->u.regex.pce->extra, ZSTR_VAL(subject), ZSTR_LEN(subject), 0, 0, NULL, 0);
                        RETVAL_BOOL(count >= 0);
                        break;