Merge branch 'PHP-7.1'

This commit is contained in:
Christoph M. Becker 2016-11-26 16:11:08 +01:00
commit 1b7e014d1c
2 changed files with 32 additions and 5 deletions

View File

@ -725,7 +725,7 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
/* Overwrite the passed-in value for subpatterns with an empty array. */
if (subpats != NULL) {
zval_dtor(subpats);
zval_ptr_dtor(subpats);
array_init(subpats);
}
@ -1591,7 +1591,7 @@ static PHP_FUNCTION(preg_replace)
replace_count = preg_replace_impl(return_value, regex, replace, subject, limit, 0, 0);
if (zcount) {
zval_dtor(zcount);
zval_ptr_dtor(zcount);
ZVAL_LONG(zcount, replace_count);
}
}
@ -1626,7 +1626,7 @@ static PHP_FUNCTION(preg_replace_callback)
replace_count = preg_replace_impl(return_value, regex, replace, subject, limit, 1, 0);
if (zcount) {
zval_dtor(zcount);
zval_ptr_dtor(zcount);
ZVAL_LONG(zcount, replace_count);
}
}
@ -1688,7 +1688,7 @@ static PHP_FUNCTION(preg_replace_callback_array)
} ZEND_HASH_FOREACH_END();
if (zcount) {
zval_dtor(zcount);
zval_ptr_dtor(zcount);
ZVAL_LONG(zcount, replace_count);
}
}
@ -1719,7 +1719,7 @@ static PHP_FUNCTION(preg_filter)
replace_count = preg_replace_impl(return_value, regex, replace, subject, limit, 0, 1);
if (zcount) {
zval_dtor(zcount);
zval_ptr_dtor(zcount);
ZVAL_LONG(zcount, replace_count);
}
}

View File

@ -0,0 +1,27 @@
--TEST--
Bug #73612 (preg_*() may leak memory)
--FILE--
<?php
$obj = new stdClass;
$obj->obj = $obj;
preg_match('/./', 'x', $obj);
$obj = new stdClass;
$obj->obj = $obj;
preg_replace('/./', '', 'x', -1, $obj);
$obj = new stdClass;
$obj->obj = $obj;
preg_replace_callback('/./', 'count', 'x', -1, $obj);
$obj = new stdClass;
$obj->obj = $obj;
preg_replace_callback_array(['/./' => 'count'], 'x', -1, $obj);
$obj = new stdClass;
$obj->obj = $obj;
preg_filter('/./', '', 'x', -1, $obj);
?>
===DONE===
--EXPECT--
===DONE===