Skip to content

Commit 59c3a7f

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: JIT: Fixed memory leak when opperand of ADD IS_VAR and IS_REFERENCE
2 parents 0007c68 + c77c79a commit 59c3a7f

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4254,29 +4254,29 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42544254
op2_addr = OP2_REG_ADDR();
42554255
if (orig_op1_type != IS_UNKNOWN
42564256
&& (orig_op1_type & IS_TRACE_REFERENCE)
4257+
&& opline->op1_type == IS_CV
42574258
&& (Z_MODE(op2_addr) != IS_REG || Z_REG(op2_addr) != ZREG_FCARG1)
42584259
&& (orig_op2_type == IS_UNKNOWN || !(orig_op2_type & IS_TRACE_REFERENCE))) {
42594260
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr,
42604261
!ssa->var_info[ssa_op->op1_use].guarded_reference, 1)) {
42614262
goto jit_failure;
42624263
}
4263-
if (opline->op1_type == IS_CV
4264-
&& ssa->vars[ssa_op->op1_use].alias == NO_ALIAS) {
4264+
if (ssa->vars[ssa_op->op1_use].alias == NO_ALIAS) {
42654265
ssa->var_info[ssa_op->op1_use].guarded_reference = 1;
42664266
}
42674267
} else {
42684268
CHECK_OP1_TRACE_TYPE();
42694269
}
42704270
if (orig_op2_type != IS_UNKNOWN
42714271
&& (orig_op2_type & IS_TRACE_REFERENCE)
4272+
&& opline->op2_type == IS_CV
42724273
&& (Z_MODE(op1_addr) != IS_REG || Z_REG(op1_addr) != ZREG_FCARG1)
42734274
&& (orig_op1_type == IS_UNKNOWN || !(orig_op1_type & IS_TRACE_REFERENCE))) {
42744275
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op2_type, &op2_info, &op2_addr,
42754276
!ssa->var_info[ssa_op->op2_use].guarded_reference, 1)) {
42764277
goto jit_failure;
42774278
}
4278-
if (opline->op2_type == IS_CV
4279-
&& ssa->vars[ssa_op->op2_use].alias == NO_ALIAS) {
4279+
if (ssa->vars[ssa_op->op2_use].alias == NO_ALIAS) {
42804280
ssa->var_info[ssa_op->op2_use].guarded_reference = 1;
42814281
}
42824282
} else {

ext/opcache/tests/jit/add_008.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
JIT ADD: 008 Addition with reference IS_VAR
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
opcache.protect_memory=1
9+
opcache.jit=tracing
10+
--EXTENSIONS--
11+
opcache
12+
--FILE--
13+
<?php
14+
($a =& $b) + ($a = 1);
15+
?>
16+
DONE
17+
--EXPECT--
18+
DONE

0 commit comments

Comments
 (0)