From 7a6ae9b14801f9f1745034888d3ed54b0b124b34 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 24 Aug 2020 16:30:49 +0200 Subject: [PATCH] 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. --- Zend/tests/bug79979.phpt | 13 +++++++++---- Zend/zend_execute_API.c | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Zend/tests/bug79979.phpt b/Zend/tests/bug79979.phpt index c41d3889e9..d655a0edce 100644 --- a/Zend/tests/bug79979.phpt +++ b/Zend/tests/bug79979.phpt @@ -2,12 +2,15 @@ Bug #79979 (passing value to by-ref param via CUF(A) crashes) --FILE-- new \stdClass]); + +\call_user_func_array("str_replace", ["a", "b", "c", new \stdClass]); +\call_user_func_array("str_replace", ["a", "b", "c", "replace_count" => new \stdClass]); -call_user_func_array($cufa, ["str_replace", ["a", "b", "c", 0]]); ?> --EXPECTF-- Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d @@ -15,3 +18,5 @@ Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d + +Warning: str_replace(): Argument #4 ($replace_count) must be passed by reference, value given in %s on line %d diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index 5a0e2a48f1..0e721c451e 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -826,6 +826,7 @@ cleanup_args: if (EXPECTED(!must_wrap)) { ZVAL_COPY(target, arg); } else { + Z_TRY_ADDREF_P(arg); ZVAL_NEW_REF(target, arg); } if (!name) { -- 2.40.0