com php-src: Fix exception handling for call_user_func_ar ray() with invalid type: Zend/tests/call_user _func_array_invalid_type.phpt Zend/zend_vm_def
.h Zend/zend_vm_execute.h
| From: | Nikita Popov | Date: | Thu, 10 Oct 2019 07:55:19 +0000 |
| Subject: | com php-src: Fix exception handling for call_user_func_ar ray() with invalid type: Zend/tests/call_user _func_array_invalid_type.phpt Zend/zend_vm_def .h Zend/zend_vm_execute.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108846@lists.php.net to get a copy of this message | ||
Commit: b093abcde3316d280825c0b1d2f797a81cd40323
Author: Nikita Popov <nikita.ppv@gmail.com> Thu, 10 Oct 2019 09:53:24 +0200
Parents: d9964efe23b8d81fa017549ae55e084d0fee401a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b093abcde3316d280825c0b1d2f797a81cd40323
Log:
Fix exception handling for call_user_func_array() with invalid type
Now that this throws an exception, the call frame cleanup will be
handled by exception handling -- remove it here to avoid double
frees.
Changed paths:
A Zend/tests/call_user_func_array_invalid_type.phpt
M Zend/zend_vm_def.h
M Zend/zend_vm_execute.h
Diff:
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
index 00000000000..d1c70f0fefd
--- /dev/null
+++ b/Zend/tests/call_user_func_array_invalid_type.phpt
@@ -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
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index ad25247b580...39fc0bd9851 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -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();
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index aeb629ced91..4fee913c327 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -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();