Skip to content

Commit cb1e842

Browse files
committed
Fix inference of COPY_TMP
Since GH-11592 COPY_TMP may receive and thus define references. Unfortunately, the name COPY_TMP is no longer accurate. Closes GH-12619
1 parent 85cb081 commit cb1e842

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ PHP NEWS
4242
. Added warning when JIT cannot be enabled. (danog)
4343
. Fixed bug GH-8143 (Crashes in zend_accel_inheritance_cache_find since
4444
upgrading to 8.1.3 due to corrupt on-disk file cache). (turchanov)
45+
. Fixed COPY_TMP type inference for references. (ilutov)
4546

4647
- OpenSSL:
4748
. Fixed bug GH-12489 (Missing sigbio creation checking in openssl_cms_verify).

Zend/Optimizer/zend_inference.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,10 @@ static zend_always_inline zend_result _zend_update_type_info(
26972697
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
26982698
COPY_SSA_OBJ_TYPE(ssa_op->op1_use, ssa_op->op1_def);
26992699
}
2700-
tmp = t1 & ~(MAY_BE_UNDEF|MAY_BE_REF);
2700+
tmp = t1 & ~MAY_BE_UNDEF;
2701+
if (opline->opcode != ZEND_COPY_TMP || opline->op1_type != IS_VAR) {
2702+
tmp &= ~MAY_BE_REF;
2703+
}
27012704
if (t1 & MAY_BE_UNDEF) {
27022705
tmp |= MAY_BE_NULL;
27032706
}

Zend/zend_vm_def.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9516,6 +9516,7 @@ ZEND_VM_HANDLER(172, ZEND_FUNC_GET_ARGS, UNUSED|CONST, UNUSED)
95169516
ZEND_VM_NEXT_OPCODE();
95179517
}
95189518

9519+
/* Contrary to what its name indicates, ZEND_COPY_TMP may receive and define references. */
95199520
ZEND_VM_HANDLER(167, ZEND_COPY_TMP, TMPVAR, UNUSED)
95209521
{
95219522
USE_OPLINE

Zend/zend_vm_execute.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)