8000 Merge branch 'PHP-7.1' · php/php-src@946eb9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 946eb9b

Browse files
committed
Merge branch 'PHP-7.1'
* PHP-7.1: Update NEWS Fixed bug #73392 (A use-after-free in zend allocator management)
2 parents c1e3fa4 + 103f633 commit 946eb9b

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

ext/pcre/php_pcre.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,10 @@ static int preg_replace_impl(zval *return_value, zval *regex, zval *replace, zva
15231523
RETVAL_STR(result);
15241524
} else {
15251525
zend_string_release(result);
1526+
RETVAL_NULL();
15261527
}
1528+
} else {
1529+
RETVAL_NULL();
15271530
}
15281531
}
15291532

@@ -1616,7 +1619,6 @@ static PHP_FUNCTION(preg_replace_callback_array)
16161619
Z_PARAM_ZVAL_EX(zcount, 0, 1)
16171620
ZEND_PARSE_PARAMETERS_END();
16181621

1619-
ZVAL_UNDEF(&zv);
16201622
ZEND_HASH_FOREACH_ 8000 STR_KEY_VAL(Z_ARRVAL_P(pattern), str_idx, replace) {
16211623
if (str_idx) {
16221624
ZVAL_STR_COPY(&regex, str_idx);
@@ -1645,10 +1647,6 @@ static PHP_FUNCTION(preg_replace_callback_array)
16451647

16461648
zval_ptr_dtor(&regex);
16471649

1648-
if (Z_ISUNDEF(zv)) {
1649-
RETURN_NULL();
1650-
}
1651-
16521650
ZVAL_COPY_VALUE(return_value, &zv);
16531651

16541652
if (UNEXPECTED(EG(exception))) {

ext/pcre/tests/bug73392.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Bug #73392 (A use-after-free in zend allocator management)
3+
--FILE--
4+
<?php
5+
class Rep {
6+
public function __invoke() {
7+
return "d";
8+
}
9+
}
10+
class Foo {
11+
public static function rep($rep) {
12+
return "ok";
13+
}
14+
}
15+
function b() {
16+
return "b";
17+
}
18+
var_dump(preg_replace_callback_array(
19+
array(
20+
"/a/" => 'b', "/b/" => function () { return "c"; }, "/c/" => new Rep, "reporting" => array("Foo", "rep"), "a1" => array("Foo", "rep"),
21+
), 'a'));
22+
?>
23+
24+
--EXPECTF--
25+
Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric or backslash in %sbug73392.php on line %d
26+
27+
Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric or backslash in %sbug73392.php on line %d
28+
NULL

0 commit comments

Comments
 (0)
0