Skip to content

Commit d4f0691

Browse files
committed
Fix incorrect RC-handling for ZEND_EXT_STMT op1
Fixes GH-21504 Closes GH-21528
1 parent e0c66a4 commit d4f0691

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PHP NEWS
77
destructors). (iliaal)
88
. Fixed ZEND_API mismatch on zend_ce_closure forward decl for Windows+Clang.
99
(henderkes)
10+
. Fixed bug GH-21504 (Incorrect RC-handling for ZEND_EXT_STMT op1). (ilutov)
1011

1112
- Iconv:
1213
. Fixed bug GH-17399 (iconv memory leak on bailout). (iliaal)

Zend/tests/gh21504.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
'1234' |> var_dump(...);

Zend/tests/gh21504.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-21504: Incorrect RC-handling for ZEND_EXT_STMT op1
3+
--FILE--
4+
<?php
5+
6+
$php_escaped = getenv('TEST_PHP_EXECUTABLE_ESCAPED');
7+
$cmd = $php_escaped . ' -n -e ' . escapeshellarg(__DIR__ . '/gh21504.inc');
8+
echo shell_exec($cmd);
9+
10+
?>
11+
--EXPECT--
12+
string(4) "1234"

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,6 +1934,9 @@ static void zend_do_extended_stmt(znode* result) /* {{{ */
19341934

19351935
opline->opcode = ZEND_EXT_STMT;
19361936
if (result) {
1937+
if (result->op_type == IS_CONST) {
1938+
Z_TRY_ADDREF(result->u.constant);
1939+
}
19371940
SET_NODE(opline->op1, result);
19381941
}
19391942
}

0 commit comments

Comments
 (0)