Skip to content

Commit e4f1083

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix finally exception chaining on recursion
2 parents 6487875 + 1a2fb90 commit e4f1083

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Test case where the implicit previous finally exception would result in recursion
3+
--FILE--
4+
<?php
5+
try {
6+
$e = new Exception("M1");
7+
try {
8+
throw new Exception("M2", 0, $e);
9+
} finally {
10+
throw $e;
11+
}
12+
} finally {}
13+
?>
14+
--EXPECTF--
15+
Fatal error: Uncaught Exception: M1 in %s:%d
16+
Stack trace:
17+
#0 {main}
18+
thrown in %s on line %d

Zend/zend_vm_def.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7772,9 +7772,8 @@ ZEND_VM_HELPER(zend_dispatch_try_catch_finally_helper, ANY, ANY, uint32_t try_ca
77727772
if (ex) {
77737773
zend_exception_set_previous(ex, Z_OBJ_P(fast_call));
77747774
} else {
7775-
EG(exception) = Z_OBJ_P(fast_call);
7775+
ex = EG(exception) = Z_OBJ_P(fast_call);
77767776
}
7777-
ex = Z_OBJ_P(fast_call);
77787777
}
77797778
}
77807779
}

Zend/zend_vm_execute.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,9 +3047,8 @@ static zend_never_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_dispatch_try
30473047
if (ex) {
30483048
zend_exception_set_previous(ex, Z_OBJ_P(fast_call));
30493049
} else {
3050-
EG(exception) = Z_OBJ_P(fast_call);
3050+
ex = EG(exception) = Z_OBJ_P(fast_call);
30513051
}
3052-
ex = Z_OBJ_P(fast_call);
30533052
}
30543053
}
30553054
}

0 commit comments

Comments
 (0)