Skip to content

Fix RC inference narrowing for ASSIGN_OBJ #13345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Zend/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -3030,12 +3030,12 @@ static zend_always_inline zend_result _zend_update_type_info(
case ZEND_ASSIGN_OBJ:
if (opline->op1_type == IS_CV) {
zend_class_entry *ce = ssa_var_info[ssa_op->op1_use].ce;
bool add_rc = !ce
bool add_rc = (t1 & (MAY_BE_OBJECT|MAY_BE_REF)) && (!ce
|| ce->__set
/* Non-default write_property may be set within create_object. */
|| ce->create_object
|| ce->default_object_handlers->write_property != zend_std_write_property
|| ssa_var_info[ssa_op->op1_use].is_instanceof;
|| ssa_var_info[ssa_op->op1_use].is_instanceof);
tmp = (t1 & (MAY_BE_REF|MAY_BE_OBJECT|MAY_BE_RC1|MAY_BE_RCN))|(add_rc ? (MAY_BE_RC1|MAY_BE_RCN) : 0);
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def);
Expand Down
14 changes: 14 additions & 0 deletions Zend/tests/oss_fuzz_66519.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
oss-fuzz #66519: Fix RC inference narrowing for ASSIGN_OBJ
--FILE--
<?php
function test() {
for (;;) {
[] ?? $oj->y = y;
$oj = new stdClass;
}
}
?>
===DONE===
--EXPECT--
===DONE===