Skip to content

Commit 1da4480

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix borked SCCP of array containing partial object
2 parents bc06688 + 1931472 commit 1da4480

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ PHP NEWS
3535
- Opcache:
3636
. Fixed bug GH-20718 ("Insufficient shared memory" when using JIT on Solaris).
3737
(Petr Sumbera)
38+
. Fixed bug GH-21227 (Borked SCCP of array containing partial object).
39+
(ilutov)
3840

3941
- Windows:
4042
. Fixed compilation with clang (missing intrin.h include). (Kévin Dunglas)

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)