diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c index 391d05ea7a7d5..8a85d12fdae79 100644 --- a/Zend/Optimizer/zend_inference.c +++ b/Zend/Optimizer/zend_inference.c @@ -2697,7 +2697,10 @@ static zend_always_inline zend_result _zend_update_type_info( UPDATE_SSA_TYPE(tmp, ssa_op->op1_def); COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def); } - tmp = t1 & ~(MAY_BE_UNDEF|MAY_BE_REF); + tmp = t1 & ~MAY_BE_UNDEF; + if (opline->opcode != ZEND_COPY_TMP || opline->op1_type != IS_VAR) { + tmp &= ~MAY_BE_REF; + } if (t1 & MAY_BE_UNDEF) { tmp |= MAY_BE_NULL; } diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 1e7110b490944..5d861444fe3d4 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -9516,6 +9516,7 @@ ZEND_VM_HANDLER(172, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED) ZEND_VM_NEXT_OPCODE(); } +/* Contrary to what its name indicates, ZEND_COPY_TMP may receive and define references. */ ZEND_VM_HANDLER(167, ZEND_COPY_TMP, TMPVAR, UNUSED) { USE_OPLINE diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 7ec1f3833ca7c..de6f814acaf6e 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -11085,6 +11085,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_CONST_UNUSE ZEND_VM_NEXT_OPCODE(); } +/* Contrary to what its name indicates, ZEND_COPY_TMP may receive and define references. */ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DIV_SPEC_CONST_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE @@ -37183,6 +37184,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FUNC_GET_ARGS_SPEC_UNUSED_UNUS ZEND_VM_NEXT_OPCODE(); } +/* Contrary to what its name indicates, ZEND_COPY_TMP may receive and define references. */ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALLABLE_CONVERT_SPEC_UNUSED_UNUSED_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE