Skip to content

Commit c77c79a

Browse files
committed
JIT: Fixed memory leak when opperand of ADD IS_VAR and IS_REFERENCE
1 parent 560dafb commit c77c79a

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
@@ -4256,29 +4256,29 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
42564256
op2_addr = OP2_REG_ADDR();
42574257
if (orig_op1_type != IS_UNKNOWN
42584258
&& (orig_op1_type & IS_TRACE_REFERENCE)
4259+
&& opline->op1_type == IS_CV
42594260
&& (Z_MODE(op2_addr) != IS_REG || Z_REG(op2_addr) != ZREG_FCARG1)
42604261
&& (orig_op2_type == IS_UNKNOWN || !(orig_op2_type & IS_TRACE_REFERENCE))) {
42614262
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op1_type, &op1_info, &op1_addr,
42624263
!ssa->var_info[ssa_op->op1_use].guarded_reference, 1)) {
42634264
goto jit_failure;
42644265
}
4265-
if (opline->op1_type == IS_CV
4266-
&& ssa->vars[ssa_op->op1_use].alias == NO_ALIAS) {
4266+
if (ssa->vars[ssa_op->op1_use].alias == NO_ALIAS) {
42674267
ssa->var_info[ssa_op->op1_use].guarded_reference = 1;
42684268
}
42694269
} else {
42704270
CHECK_OP1_TRACE_TYPE();
42714271
}
42724272
if (orig_op2_type != IS_UNKNOWN
42734273
&& (orig_op2_type & IS_TRACE_REFERENCE)
4274+
&& opline->op2_type == IS_CV
42744275
&& (Z_MODE(op1_addr) != IS_REG || Z_REG(op1_addr) != ZREG_FCARG1)
42754276
&& (orig_op1_type == IS_UNKNOWN || !(orig_op1_type & IS_TRACE_REFERENCE))) {
42764277
if (!zend_jit_fetch_reference(&dasm_state, opline, orig_op2_type, &op2_info, &op2_addr,
42774278
!ssa->var_info[ssa_op->op2_use].guarded_reference, 1)) {
42784279
goto jit_failure;
42794280
}
4280-
if (opline->op2_type == IS_CV
4281-
&& ssa->vars[ssa_op->op2_use].alias == NO_ALIAS) {
4281+
if (ssa->vars[ssa_op->op2_use].alias == NO_ALIAS) {
42824282
ssa->var_info[ssa_op->op2_use].guarded_reference = 1;
42834283
}
42844284
} 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)