mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Improve ZEND_NEW RC inference
ZEND_NEW returns RC1 if the instanciated class has no constructor. Closes GH-13239
This commit is contained in:
@@ -3376,9 +3376,19 @@ static zend_always_inline zend_result _zend_update_type_info(
|
||||
UPDATE_SSA_OBJ_TYPE(ce, 0, ssa_op->result_def);
|
||||
} else if ((t1 & MAY_BE_CLASS) && ssa_op->op1_use >= 0 && ssa_var_info[ssa_op->op1_use].ce) {
|
||||
UPDATE_SSA_OBJ_TYPE(ssa_var_info[ssa_op->op1_use].ce, ssa_var_info[ssa_op->op1_use].is_instanceof, ssa_op->result_def);
|
||||
if (!ssa_var_info[ssa_op->result_def].is_instanceof) {
|
||||
ce = ssa_var_info[ssa_op->op1_use].ce;
|
||||
}
|
||||
} else {
|
||||
UPDATE_SSA_OBJ_TYPE(NULL, 0, ssa_op->result_def);
|
||||
}
|
||||
/* New objects without constructors cannot escape. */
|
||||
if (ce
|
||||
&& !ce->constructor
|
||||
&& !ce->create_object
|
||||
&& ce->default_object_handlers->get_constructor == zend_std_get_constructor) {
|
||||
tmp &= ~MAY_BE_RCN;
|
||||
}
|
||||
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
|
||||
break;
|
||||
case ZEND_CLONE:
|
||||
|
||||
Reference in New Issue
Block a user