com php-src: Fixed bug #70868 (PCRE JIT and pattern reuse segfault): Zend/tests/bug70868.phpt ext/spl/spl_iterators.c ext/spl/ tests/bug70868.phpt

From: Date: Sun, 08 Nov 2015 03:27:25 +0000
Subject: com php-src: Fixed bug #70868 (PCRE JIT and pattern reuse segfault): Zend/tests/bug70868.phpt ext/spl/spl_iterators.c ext/spl/ tests/bug70868.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89710@lists.php.net to get a copy of this message
Commit: 3d8c4a37a528941a84d5bd7f7e6439d267e43776 Author: Xinchen Hui <laruence@gmail.com> Fri, 6 Nov 2015 11:37:17 +0800 Committer: Anatol Belski <ab@php.net> Sun, 8 Nov 2015 04:27:25 +0100 Parents: 973a64e17d375ef3ae1a7b662b00204e3ecb061e Branches: PHP-7.0.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3d8c4a37a528941a84d5bd7f7e6439d267e43776 Log: Fixed bug #70868 (PCRE JIT and pattern reuse segfault) Bugs: https://bugs.php.net/70868 Changed paths: D Zend/tests/bug70868.phpt M ext/spl/spl_iterators.c A ext/spl/tests/bug70868.phpt Diff: diff --git a/Zend/tests/bug70868.phpt b/Zend/tests/bug70868.phpt deleted file mode 100644 index d3dd763..0000000 --- a/Zend/tests/bug70868.phpt +++ /dev/null @@ -1,32 +0,0 @@ ---TEST-- -Bug #70868, with PCRE JIT ---INI-- -pcre.jit=1 ---SKIPIF-- -<?php if (!extension_loaded("pcre")) die("skip"); ?> ---FILE-- -<?php - -namespace X; - -$iterator = - new \RegexIterator( - new \ArrayIterator(['A.phpt', 'B.phpt', 'C.phpt']), - '/\.phpt$/' - ) -; - -foreach ($iterator as $foo) { - var_dump($foo); - preg_replace('/\.phpt$/', '', ''); -} - -echo "Done", PHP_EOL; - -?> ---EXPECTF-- - -string(6) "A.phpt" -string(6) "B.phpt" -string(6) "C.phpt" -Done diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index cd0c624..b29fc52 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -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; diff --git a/ext/spl/tests/bug70868.phpt b/ext/spl/tests/bug70868.phpt new file mode 100644 index 0000000..d3dd763 --- /dev/null +++ b/ext/spl/tests/bug70868.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #70868, with PCRE JIT +--INI-- +pcre.jit=1 +--SKIPIF-- +<?php if (!extension_loaded("pcre")) die("skip"); ?> +--FILE-- +<?php + +namespace X; + +$iterator = + new \RegexIterator( + new \ArrayIterator(['A.phpt', 'B.phpt', 'C.phpt']), + '/\.phpt$/' + ) +; + +foreach ($iterator as $foo) { + var_dump($foo); + preg_replace('/\.phpt$/', '', ''); +} + +echo "Done", PHP_EOL; + +?> +--EXPECTF-- + +string(6) "A.phpt" +string(6) "B.phpt" +string(6) "C.phpt" +Done

« previous php.cvs (#89710) next »