Skip to content

Commit 94c8e01

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix borked SCCP of array containing partial object
2 parents e64ac18 + 1da4480 commit 94c8e01

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

Zend/Optimizer/sccp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
968968
SET_RESULT(op1, &zv);
969969
} else if (ct_eval_assign_dim(&zv, data, op2) == SUCCESS) {
970970
/* Mark array containing partial array as partial */
971-
if (IS_PARTIAL_ARRAY(data)) {
971+
if (IS_PARTIAL_ARRAY(data) || IS_PARTIAL_OBJECT(data)) {
972972
MAKE_PARTIAL_ARRAY(&zv);
973973
}
974974
SET_RESULT(result, data);
@@ -1173,7 +1173,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
11731173
/* We can't add NEXT element into partial array (skip it) */
11741174
SET_RESULT(result, &zv);
11751175
} else if (ct_eval_add_array_elem(&zv, op1, op2) == SUCCESS) {
1176-
if (IS_PARTIAL_ARRAY(op1)) {
1176+
if (IS_PARTIAL_ARRAY(op1) || IS_PARTIAL_OBJECT(op1)) {
11771177
MAKE_PARTIAL_ARRAY(&zv);
11781178
}
11791179
SET_RESULT(result, &zv);

ext/opcache/tests/gh21227.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
GH-21227: Borked SCCP of array containing partial object
3+
--CREDITS--
4+
Daniel Chong (chongwick)
5+
--EXTENSIONS--
6+
opcache
7+
--INI--
8+
opcache.enable=1
9+
opcache.enable_cli=1
10+
--FILE--
11+
<?php
12+
13+
function test() {
14+
$obj->a = 3;
15+
$objs = [];
16+
$obj = new stdClass;
17+
$objs[] = $obj;
18+
}
19+
20+
?>
21+
===DONE===
22+
--EXPECT--
23+
===DONE===

0 commit comments

Comments
 (0)