Skip to content

Commit 41f33b9

Browse files
committed
Don't use CE info from pi node for MAY_BE_REF var
Once again, the actual class type may be reassigned indirectly.
1 parent b08aac0 commit 41f33b9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Zend/tests/assign_obj_to_ref_inference.phpt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,27 @@ class Test {
77
public int $x = 42;
88
}
99

10-
function test() {
10+
function test1() {
1111
$r =& $o;
1212
$o = new Test;
1313
$r = new stdClass;
1414
$r->x = 3.141;
1515
var_dump(is_float($o->x));
1616
}
17-
test();
17+
18+
function test2($o) {
19+
$r =& $o;
20+
if ($o instanceof Test) {
21+
$r = new stdClass;
22+
$r->x = 3.141;
23+
var_dump(is_float($o->x));
24+
}
25+
}
26+
27+
test1();
28+
test2(new Test);
1829

1930
?>
2031
--EXPECT--
2132
bool(true)
33+
bool(true)

ext/opcache/Optimizer/zend_inference.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,11 @@ int zend_infer_types_ex(const zend_op_array *op_array, const zend_script *script
36293629
}
36303630

36313631
UPDATE_SSA_TYPE(tmp, j);
3632-
UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j);
3632+
if (tmp & MAY_BE_REF) {
3633+
UPDATE_SSA_OBJ_TYPE(NULL, 0, j);
3634+
} else {
3635+
UPDATE_SSA_OBJ_TYPE(ce, is_instanceof, j);
3636+
}
36333637
} else {
36343638
int first = 1;
36353639
int is_instanceof = 0;

0 commit comments

Comments
 (0)