]> granicus.if.org Git - php/commitdiff
Fixed bug #70012 (Exception lost with nested finally block)
authorXinchen Hui <laruence@php.net>
Wed, 8 Jul 2015 09:14:19 +0000 (17:14 +0800)
committerXinchen Hui <laruence@php.net>
Wed, 8 Jul 2015 09:14:19 +0000 (17:14 +0800)
NEWS
Zend/tests/bug70012.phpt [new file with mode: 0644]
Zend/zend_vm_def.h
Zend/zend_vm_execute.h

diff --git a/NEWS b/NEWS
index a8cf659c05312368cfd144cc289fa0856a327e2b..d4a456115058b82b55efb0d7c94ac9d9c40cc538 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Jul 2015, PHP 5.6.12
 
+- Core:
+  . Fixed bug #70012 (Exception lost with nested finally block). (Laruence)
+
 - CLI server:
   . Fixed bug #69655 (php -S changes MKCALENDAR request method to MKCOL). (cmb)
   . Fixed bug #64878 (304 responses return Content-Type header). (cmb)
diff --git a/Zend/tests/bug70012.phpt b/Zend/tests/bug70012.phpt
new file mode 100644 (file)
index 0000000..5337649
--- /dev/null
@@ -0,0 +1,32 @@
+--TEST--
+Bug #70012 (Exception lost with nested finally block)
+--FILE--
+<?php
+try {
+       echo "Outer try\n";
+       try {
+               echo "  Middle try\n";
+               throw new Exception();
+       } finally {
+               echo "  Middle finally\n";
+               try {
+                       echo "    Inner try\n";
+               } finally {
+                       echo "    Inner finally\n";
+               }
+       }
+       echo "Outer shouldnt get here\n";
+} catch (Exception $e) {
+       echo "Outer catch\n";
+} finally {
+       echo "Outer finally\n";
+}
+?>
+--EXPECT--
+Outer try
+  Middle try
+  Middle finally
+    Inner try
+    Inner finally
+Outer catch
+Outer finally
index c7b2d2a93473881021bc6c0164273a9cfaf6fb72..11f62053b18e4183d364540254cf634580d500a5 100644 (file)
@@ -5650,8 +5650,11 @@ ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY)
                ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]);
                ZEND_VM_CONTINUE();
        }
-       EX(fast_ret) = opline;
-       EX(delayed_exception) = NULL;
+       if (UNEXPECTED(EX(delayed_exception) != NULL)) {
+               EX(fast_ret) = NULL;
+       } else {
+               EX(fast_ret) = opline;
+       }       
        ZEND_VM_SET_OPCODE(opline->op1.jmp_addr);
        ZEND_VM_CONTINUE();
 }
index 0de6b4ab57d8a2529a39cc3d9cb8ad618dbc050c..5ed4135c5960ae9d6f67ca753ab82ea60c33d3e6 100644 (file)
@@ -1354,8 +1354,11 @@ static int ZEND_FASTCALL  ZEND_FAST_CALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
                ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]);
                ZEND_VM_CONTINUE();
        }
-       EX(fast_ret) = opline;
-       EX(delayed_exception) = NULL;
+       if (UNEXPECTED(EX(delayed_exception) != NULL)) {
+               EX(fast_ret) = NULL;
+       } else {
+               EX(fast_ret) = opline;
+       }
        ZEND_VM_SET_OPCODE(opline->op1.jmp_addr);
        ZEND_VM_CONTINUE();
 }