Skip to content

Commit 1931472

Browse files
committed
Fix borked SCCP of array containing partial object
In SCCP, arrays containing partial objects must be marked as partial so that their values are not accidentally propagated. Fixes GH-21227 Closes GH-21232
1 parent dc977ef commit 1931472

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

NEWS

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

3840
- PDO_PGSQL:
3941
. Fixed bug GH-21055 (connection attribute status typo for GSS negotiation).

Zend/Optimizer/sccp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
965965
SET_RESULT(op1, &zv);
966966
} else if (ct_eval_assign_dim(&zv, data, op2) == SUCCESS) {
967967
/* Mark array containing partial array as partial */
968-
if (IS_PARTIAL_ARRAY(data)) {
968+
if (IS_PARTIAL_ARRAY(data) || IS_PARTIAL_OBJECT(data)) {
969969
MAKE_PARTIAL_ARRAY(&zv);
970970
}
971971
SET_RESULT(result, data);
@@ -1165,7 +1165,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
11651165
/* We can't add NEXT element into partial array (skip it) */
11661166
SET_RESULT(result, &zv);
11671167
} else if (ct_eval_add_array_elem(&zv, op1, op2) == SUCCESS) {
1168-
if (IS_PARTIAL_ARRAY(op1)) {
1168+
if (IS_PARTIAL_ARRAY(op1) || IS_PARTIAL_OBJECT(op1)) {
11691169
MAKE_PARTIAL_ARRAY(&zv);
11701170
}
11711171
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)