Commit 9e9b309b6fa for php.net
commit 9e9b309b6faa4f9bfe7f6edfaf508dd3c5599743
Author: Pratik Bhujel <prateekbhujelpb@gmail.com>
Date: Sun Jun 14 18:56:32 2026 +0545
Fix GH-22280: Ignore non-finally try blocks (#22286)
diff --git a/NEWS b/NEWS
index 3ec0d319b7e..7b36fb24679 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 8.4.23
+- Core:
+ . Fixed bug GH-22280 (Incorrect compile error for goto to label preceding
+ try/finally block). (Pratik Bhujel)
+
- BCMath:
. Fixed issues with oversized allocations and signed overflow in bcround()
and BcMath\Number::round(). (edorian)
diff --git a/Zend/tests/try/gh22280.phpt b/Zend/tests/try/gh22280.phpt
new file mode 100644
index 00000000000..30944aff59a
--- /dev/null
+++ b/Zend/tests/try/gh22280.phpt
@@ -0,0 +1,19 @@
+--TEST--
+GH-22280: goto to label before try/finally after try/catch
+--FILE--
+<?php
+goto d;
+try {
+} catch (Throwable) {
+}
+d: try {
+ echo "try\n";
+} finally {
+ echo "finally\n";
+}
+echo "done\n";
+?>
+--EXPECT--
+try
+finally
+done
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 7a364dfccbc..317f68b486b 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -684,6 +684,10 @@ static void zend_check_finally_breakout(zend_op_array *op_array, uint32_t op_num
int i;
for (i = 0; i < op_array->last_try_catch; i++) {
+ if (!op_array->try_catch_array[i].finally_op) {
+ continue;
+ }
+
if ((op_num < op_array->try_catch_array[i].finally_op ||
op_num >= op_array->try_catch_array[i].finally_end)
&& (dst_num >= op_array->try_catch_array[i].finally_op &&