Skip to content

Commit 3b8f9d9

Browse files
committed
Accurate handling of ZEND_ASSIGN_OBJ
1 parent 5155bf1 commit 3b8f9d9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,6 +4176,43 @@ int zend_may_throw(const zend_op *opline, zend_op_array *op_array, zend_ssa *ssa
41764176
case ZEND_ASSIGN_DIM:
41774177
return (t1 & (MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_TRUE|MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE)) || opline->op2_type == IS_UNUSED ||
41784178
(t2 & (MAY_BE_UNDEF|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
4179+
case ZEND_ASSIGN_OBJ:
4180+
if (t1 & (MAY_BE_ANY-(MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_OBJECT))) {
4181+
return 1;
4182+
}
4183+
if (ssa->ops[opline - op_array->opcodes].op1_use) {
4184+
zend_ssa_var_info *var_info = ssa->var_info + ssa->ops[opline - op_array->opcodes].op1_use;
4185+
zend_class_entry *ce = var_info->ce;
4186+
4187+
if (var_info->is_instanceof ||
4188+
!ce || ce->create_object || ce->__get || ce->__set ||
4189+
(ce->ce_flags & ZEND_ACC_INHERITED)) {
4190+
return 1;
4191+
}
4192+
4193+
if (op_array->scope != ce && ce->default_properties_count) {
4194+
zend_property_info *prop_info;
4195+
4196+
if (opline->op2_type == IS_CONST) {
4197+
prop_info = zend_hash_find_ptr(&ce->properties_info,
4198+
Z_STR_P(CRT_CONSTANT_EX(op_array, opline->op2, ssa->rt_constants)));
4199+
if (prop_info && !(prop_info->flags & ZEND_ACC_PUBLIC)) {
4200+
return 1;
4201+
}
4202+
} else {
4203+
if (t2 & (MAY_BE_ANY-MAY_BE_STRING)) {
4204+
return 1;
4205+
}
4206+
ZEND_HASH_FOREACH_PTR(&ce->properties_info, prop_info) {
4207+
if (!(prop_info->flags & ZEND_ACC_PUBLIC)) {
4208+
return 1;
4209+
}
4210+
} ZEND_HASH_FOREACH_END();
4211+
}
4212+
}
4213+
return 0;
4214+
}
4215+
return 1;
41794216
case ZEND_ROPE_INIT:
41804217
case ZEND_ROPE_ADD:
41814218
case ZEND_ROPE_END:

0 commit comments

Comments
 (0)