Skip to content

Commit 7a6ae9b

Browse files
committed
Fix refcounting for the named params case as well
Adjust the test case to pass a refcounted value and to also check the named params case.
1 parent 779e904 commit 7a6ae9b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Zend/tests/bug79979.phpt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
Bug #79979 (passing value to by-ref param via CUF(A) crashes)
33
--FILE--
44
<?php
5-
call_user_func_array("str_replace", ["a", "b", "c", 0]);
65

7-
$cufa = "call_user_func_array";
8-
$cufa("str_replace", ["a", "b", "c", 0]);
6+
namespace Foo;
7+
8+
call_user_func_array("str_replace", ["a", "b", "c", new \stdClass]);
9+
call_user_func_array("str_replace", ["a", "b", "c", "replace_count" => new \stdClass]);
10+
11+
\call_user_func_array("str_replace", ["a", "b", "c", new \stdClass]);
12+
\call_user_func_array("str_replace", ["a", "b", "c", "replace_count" => new \stdClass]);
913

10-
call_user_func_array($cufa, ["str_replace", ["a", "b", "c", 0]]);
1114
?>
1215
--EXPECTF--
1316
Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d
1417

1518
Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d
1619

1720
Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d
21+
22+
Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d

Zend/zend_execute_API.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
826826
if (EXPECTED(!must_wrap)) {
827827
ZVAL_COPY(target, arg);
828828
} else {
829+
Z_TRY_ADDREF_P(arg);
829830
ZVAL_NEW_REF(target, arg);
830831
}
831832
if (!name) {

0 commit comments

Comments
 (0)