From f44e67b34431b82a937b4bf1271e9ec805eceaf1 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Wed, 25 Mar 2026 16:54:32 +0100 Subject: [PATCH] Fix incorrect RC-handling for ZEND_EXT_STMT op1 Fixes GH-21504 --- Zend/tests/gh21504.inc | 3 +++ Zend/tests/gh21504.phpt | 12 ++++++++++++ Zend/zend_compile.c | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 Zend/tests/gh21504.inc create mode 100644 Zend/tests/gh21504.phpt diff --git a/Zend/tests/gh21504.inc b/Zend/tests/gh21504.inc new file mode 100644 index 0000000000000..71dc5c2e61f64 --- /dev/null +++ b/Zend/tests/gh21504.inc @@ -0,0 +1,3 @@ + var_dump(...); diff --git a/Zend/tests/gh21504.phpt b/Zend/tests/gh21504.phpt new file mode 100644 index 0000000000000..5fd9eaff91ab6 --- /dev/null +++ b/Zend/tests/gh21504.phpt @@ -0,0 +1,12 @@ +--TEST-- +GH-21504: Incorrect RC-handling for ZEND_EXT_STMT op1 +--FILE-- + +--EXPECT-- +string(4) "1234" diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 80f85f421a331..8c748fc8ccc4c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -1934,6 +1934,9 @@ static void zend_do_extended_stmt(znode* result) /* {{{ */ opline->opcode = ZEND_EXT_STMT; if (result) { + if (result->op_type == IS_CONST) { + Z_TRY_ADDREF(result->u.constant); + } SET_NODE(opline->op1, result); } }