Skip to content

Commit 4183db6

Browse files
committed
Fix RC inference narrowing for ASSIGN_OBJ
Fixes oss-fuzz #6519
1 parent f9cfd40 commit 4183db6

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Zend/Optimizer/zend_inference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,12 +3030,12 @@ static zend_always_inline zend_result _zend_update_type_info(
30303030
case ZEND_ASSIGN_OBJ:
30313031
if (opline->op1_type == IS_CV) {
30323032
zend_class_entry *ce = ssa_var_info[ssa_op->op1_use].ce;
3033-
bool add_rc = !ce
3033+
bool add_rc = (t1 & (MAY_BE_OBJECT|MAY_BE_REF)) && (!ce
30343034
|| ce->__set
30353035
/* Non-default write_property may be set within create_object. */
30363036
|| ce->create_object
30373037
|| ce->default_object_handlers->write_property != zend_std_write_property
3038-
|| ssa_var_info[ssa_op->op1_use].is_instanceof;
3038+
|| ssa_var_info[ssa_op->op1_use].is_instanceof);
30393039
tmp = (t1 & (MAY_BE_REF|MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN))|(add_rc ? (MAY_BE_RC1|MAY_BE_RCN) : 0);
30403040
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
30413041
COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def);

Zend/tests/oss_fuzz_66519.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
oss-fuzz #66519: Fix RC inference narrowing for ASSIGN_OBJ
3+
--FILE--
4+
<?php
5+
function test() {
6+
for (;;) {
7+
[] ?? $oj->y = y;
8+
$oj = new stdClass;
9+
}
10+
}
11+
?>
12+
===DONE===
13+
--EXPECT--
14+
===DONE===

0 commit comments

Comments
 (0)