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); } }