1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Improve ASSIGN_OBJ RC inference

ASSIGN_OBJ may only modify RC if it implements __set.

Closes GH-13237
This commit is contained in:
Ilija Tovilo
2024-01-24 15:42:57 +01:00
parent cc5a39458c
commit 668edf2cae

View File

@@ -3029,7 +3029,14 @@ static zend_always_inline zend_result _zend_update_type_info(
break;
case ZEND_ASSIGN_OBJ:
if (opline->op1_type == IS_CV) {
tmp = (t1 & (MAY_BE_REF|MAY_BE_OBJECT))|MAY_BE_RC1|MAY_BE_RCN;
zend_class_entry *ce = ssa_var_info[ssa_op->op1_use].ce;
bool add_rc = !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;
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);
}