]> granicus.if.org Git - php/commitdiff
Fix RECV opcode to handle all kinds of exceptions
authorNikita Nefedov <inefedor@gmail.com>
Tue, 19 Apr 2016 16:26:08 +0000 (19:26 +0300)
committernikita2206 <inefedor@gmail.com>
Wed, 20 Apr 2016 08:56:07 +0000 (11:56 +0300)
fix RECV opcode to handle exceptions thrown from user-defined error handler
as a result Notice error from failed type coercion

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

diff --git a/Zend/tests/bug72057.phpt b/Zend/tests/bug72057.phpt
new file mode 100644 (file)
index 0000000..e1a129b
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #72057 (PHP hangs when user error handler throws exception after Notice from type coercion)
+--FILE--
+<?php
+
+set_error_handler(
+    function() {
+        throw new Exception("My custom error");
+    }
+);
+
+(function (int $i) { bar(); })("7as");
+
+--EXPECTF--
+
+Fatal error: Uncaught Exception: My custom error in %s:%d
+Stack trace:
+#0 %s(%d): {closure}(8, 'A non well form...', '%s', %d, Array)
+#1 %s(%d): {closure}('7as')
+#2 {main}
+  thrown in %s on line %d
index 1b1137df83fc7839c0cbb7d8c35eec0770aa9f0f..687493f37b8bca2b769106f0d96a8e9bd700081e 100644 (file)
@@ -4704,7 +4704,7 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
                zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
 
                SAVE_OPLINE();
-               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num)))) {
+               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num)) || EG(exception))) {
                        HANDLE_EXCEPTION();
                }
        }
@@ -4742,7 +4742,7 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
                zval *default_value = EX_CONSTANT(opline->op2);
 
                SAVE_OPLINE();
-               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))))) {
+               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))) || EG(exception))) {
                        HANDLE_EXCEPTION();
                }
        }
index 98fa5e5e729e6cbb7612e134612d38b11e4f8dc2..2746c4000cee08c939cb4fc4d42a91a1f7fea230 100644 (file)
@@ -1188,7 +1188,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_SPEC_HANDLER(ZEND_OPCODE_
                zval *param = _get_zval_ptr_cv_undef_BP_VAR_W(execute_data, opline->result.var);
 
                SAVE_OPLINE();
-               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num)))) {
+               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, NULL, CACHE_ADDR(opline->op2.num)) || EG(exception))) {
                        HANDLE_EXCEPTION();
                }
        }
@@ -2208,7 +2208,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_RECV_INIT_SPEC_CONST_HANDLER(Z
                zval *default_value = EX_CONSTANT(opline->op2);
 
                SAVE_OPLINE();
-               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))))) {
+               if (UNEXPECTED(!zend_verify_arg_type(EX(func), arg_num, param, default_value, CACHE_ADDR(Z_CACHE_SLOT_P(default_value))) || EG(exception))) {
                        HANDLE_EXCEPTION();
                }
        }