]> granicus.if.org Git - php/commitdiff
Fix exception handling for call_user_func_array() with invalid type
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Oct 2019 07:53:24 +0000 (09:53 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Thu, 10 Oct 2019 07:55:19 +0000 (09:55 +0200)
Now that this throws an exception, the call frame cleanup will be
handled by exception handling -- remove it here to avoid double
frees.

Zend/tests/call_user_func_array_invalid_type.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/Zend/tests/call_user_func_array_invalid_type.phpt b/Zend/tests/call_user_func_array_invalid_type.phpt
new file mode 100644 (file)
index 0000000..d1c70f0
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+call_user_func_array() generating TypeError
+--FILE--
+<?php
+class drv {
+    function func() {
+    }
+}
+
+$drv = new drv;
+try {
+    call_user_func_array(array($drv, 'func'), null);
+} catch (TypeError $e) {
+    echo $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+call_user_func_array() expects parameter 2 to be array, null given
index ad25247b580145291d4edee1801e9da4b59e5ffc..39fc0bd985186a566d9eee48de2ca70ff1995b5e 100644 (file)
@@ -4950,11 +4950,6 @@ ZEND_VM_HANDLER(119, ZEND_SEND_ARRAY, ANY, ANY, NUM)
                        }
                }
                zend_type_error("call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
-               if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
-                       OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(call)->func));
-               } else if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_RELEASE_THIS) {
-                       OBJ_RELEASE(Z_OBJ(EX(call)->This));
-               }
                FREE_UNFETCHED_OP2();
                FREE_OP1();
                HANDLE_EXCEPTION();
index aeb629ced919420d9840a00574c7407ce0f5e928..4fee913c327588d1a6081c2982f11bd37899a231 100644 (file)
@@ -1968,11 +1968,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O
                        }
                }
                zend_type_error("call_user_func_array() expects parameter 2 to be array, %s given", zend_get_type_by_const(Z_TYPE_P(args)));
-               if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_CLOSURE) {
-                       OBJ_RELEASE(ZEND_CLOSURE_OBJECT(EX(call)->func));
-               } else if (ZEND_CALL_INFO(EX(call)) & ZEND_CALL_RELEASE_THIS) {
-                       OBJ_RELEASE(Z_OBJ(EX(call)->This));
-               }
                FREE_UNFETCHED_OP(opline->op2_type, opline->op2.var);
                FREE_OP(opline->op1_type, opline->op1.var);
                HANDLE_EXCEPTION();