]> granicus.if.org Git - php/commitdiff
FIxed bug #80299
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 30 Oct 2020 16:23:18 +0000 (17:23 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 30 Oct 2020 16:23:18 +0000 (17:23 +0100)
The must_wrap was leaking across iterations.

NEWS
Zend/zend_execute_API.c
ext/reflection/tests/bug80299.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 0884c32f3fc4317720952aeff9802c7e26a75c9d..2f45f378c135f3799dde7eb3e09b8845472f4818 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ PHP                                                                        NEWS
 - Opcache:
   . Fixed run-time binding of preloaded dynamically declared function. (Dmitry)
 
+- Reflection:
+  . Fixed bug #80299 (ReflectionFunction->invokeArgs confused in arguments).
+    (Nikita)
+
 - Standard:
   . Don't force rebuild of symbol table, when populating $http_response_header
     variable by the HTTP stream wrapper. (Dmitry)
index 7572a0d8900c6173a338d66375a1258467f98111..42482122389e6bc7c54324c25e8fa490819dbde7 100644 (file)
@@ -807,8 +807,8 @@ cleanup_args:
                zval *arg;
                uint32_t arg_num = ZEND_CALL_NUM_ARGS(call) + 1;
                zend_bool have_named_params = 0;
-               zend_bool must_wrap = 0;
                ZEND_HASH_FOREACH_STR_KEY_VAL(fci->named_params, name, arg) {
+                       zend_bool must_wrap = 0;
                        zval *target;
                        if (name) {
                                void *cache_slot[2] = {NULL, NULL};
diff --git a/ext/reflection/tests/bug80299.phpt b/ext/reflection/tests/bug80299.phpt
new file mode 100644 (file)
index 0000000..61aec5b
--- /dev/null
@@ -0,0 +1,15 @@
+--TEST--
+Bug #80299: ReflectionFunction->invokeArgs confused in arguments
+--FILE--
+<?php
+
+$bar = new DateTime();
+$args = [1, &$bar];
+
+$function = function (int &$foo, DateTimeInterface &$bar) {};
+
+(new ReflectionFunction($function))->invokeArgs($args);
+
+?>
+--EXPECTF--
+Warning: {closure}(): Argument #1 ($foo) must be passed by reference, value given in %s on line %d