Skip to content

Commit a7ea6ec

Browse files
committed
Fix memory leaks
1 parent 8d9b682 commit a7ea6ec

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

ext/opcache/jit/zend_jit_ir.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15405,6 +15405,7 @@ static int zend_jit_ffi_assign_obj(zend_jit_ctx *jit,
1540515405
const zend_ssa_op *ssa_op,
1540615406
uint32_t op1_info,
1540715407
zend_jit_addr op1_addr,
15408+
bool op1_indirect,
1540815409
bool on_this,
1540915410
bool delayed_fetch_this,
1541015411
zend_ffi_field *field,
@@ -15432,6 +15433,10 @@ static int zend_jit_ffi_assign_obj(zend_jit_ctx *jit,
1543215433

1543315434
ZEND_ASSERT(!res_addr);
1543415435

15436+
if (opline->op1_type != IS_UNUSED && !delayed_fetch_this && !op1_indirect) {
15437+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
15438+
}
15439+
1543515440
return 1;
1543615441
}
1543715442

@@ -15442,6 +15447,7 @@ static int zend_jit_ffi_assign_sym(zend_jit_ctx *jit,
1544215447
const zend_ssa_op *ssa_op,
1544315448
uint32_t op1_info,
1544415449
zend_jit_addr op1_addr,
15450+
bool op1_indirect,
1544515451
bool on_this,
1544615452
bool delayed_fetch_this,
1544715453
zend_ffi_symbol *sym,
@@ -15466,6 +15472,10 @@ static int zend_jit_ffi_assign_sym(zend_jit_ctx *jit,
1546615472

1546715473
ZEND_ASSERT(!res_addr);
1546815474

15475+
if (opline->op1_type != IS_UNUSED && !delayed_fetch_this && !op1_indirect) {
15476+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
15477+
}
15478+
1546915479
return 1;
1547015480
}
1547115481
#endif
@@ -15831,6 +15841,7 @@ static int zend_jit_ffi_assign_obj_op(zend_jit_ctx *jit,
1583115841
const zend_ssa_op *ssa_op,
1583215842
uint32_t op1_info,
1583315843
zend_jit_addr op1_addr,
15844+
bool op1_indirect,
1583415845
bool on_this,
1583515846
bool delayed_fetch_this,
1583615847
zend_ffi_field *field,
@@ -15854,6 +15865,10 @@ static int zend_jit_ffi_assign_obj_op(zend_jit_ctx *jit,
1585415865
return 0;
1585515866
}
1585615867

15868+
if (opline->op1_type != IS_UNUSED && !delayed_fetch_this && !op1_indirect) {
15869+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
15870+
}
15871+
1585715872
return 1;
1585815873
}
1585915874

@@ -15864,6 +15879,7 @@ static int zend_jit_ffi_assign_sym_op(zend_jit_ctx *jit,
1586415879
const zend_ssa_op *ssa_op,
1586515880
uint32_t op1_info,
1586615881
zend_jit_addr op1_addr,
15882+
bool op1_indirect,
1586715883
bool on_this,
1586815884
bool delayed_fetch_this,
1586915885
zend_ffi_symbol *sym,
@@ -15884,6 +15900,10 @@ static int zend_jit_ffi_assign_sym_op(zend_jit_ctx *jit,
1588415900
return 0;
1588515901
}
1588615902

15903+
if (opline->op1_type != IS_UNUSED && !delayed_fetch_this && !op1_indirect) {
15904+
jit_FREE_OP(jit, opline->op1_type, opline->op1, op1_info, opline);
15905+
}
15906+
1588715907
return 1;
1588815908
}
1588915909
#endif

ext/opcache/jit/zend_jit_trace.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
49274927
ffi_info = zend_arena_calloc(&CG(arena), ssa->vars_count, sizeof(zend_jit_ffi_info));
49284928
}
49294929
if (!zend_jit_ffi_assign_obj_op(&ctx, opline, op_array, ssa, ssa_op,
4930-
op1_info, op1_addr, on_this, delayed_fetch_this, field,
4930+
op1_info, op1_addr, op1_indirect, on_this, delayed_fetch_this, field,
49314931
op1_data_info, OP1_DATA_REG_ADDR(),
49324932
op1_ffi_type, ffi_info)) {
49334933
goto jit_failure;
@@ -4944,7 +4944,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
49444944
ffi_info = zend_arena_calloc(&CG(arena), ssa->vars_count, sizeof(zend_jit_ffi_info));
49454945
}
49464946
if (!zend_jit_ffi_assign_sym_op(&ctx, opline, op_array, ssa, ssa_op,
4947-
op1_info, op1_addr, on_this, delayed_fetch_this, sym,
4947+
op1_info, op1_addr, op1_indirect, on_this, delayed_fetch_this, sym,
49484948
op1_data_info, OP1_DATA_REG_ADDR(),
49494949
op1_ffi_symbols, ffi_info)) {
49504950
goto jit_failure;
@@ -5049,7 +5049,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
50495049
ffi_info = zend_arena_calloc(&CG(arena), ssa->vars_count, sizeof(zend_jit_ffi_info));
50505050
}
50515051
if (!zend_jit_ffi_assign_obj(&ctx, opline, op_array, ssa, ssa_op,
5052-
op1_info, op1_addr, on_this, delayed_fetch_this, field,
5052+
op1_info, op1_addr, op1_indirect, on_this, delayed_fetch_this, field,
50535053
op1_data_info, OP1_DATA_REG_ADDR(), OP1_DATA_DEF_REG_ADDR(),
50545054
(opline->result_type != IS_UNUSED) ? RES_REG_ADDR() : 0,
50555055
op1_ffi_type, op3_ffi_type, ffi_info)) {
@@ -5072,7 +5072,7 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par
50725072
ffi_info = zend_arena_calloc(&CG(arena), ssa->vars_count, sizeof(zend_jit_ffi_info));
50735073
}
50745074
if (!zend_jit_ffi_assign_sym(&ctx, opline, op_array, ssa, ssa_op,
5075-
op1_info, op1_addr, on_this, delayed_fetch_this, sym,
5075+
op1_info, op1_addr, op1_indirect, on_this, delayed_fetch_this, sym,
50765076
op1_data_info, OP1_DATA_REG_ADDR(), OP1_DATA_DEF_REG_ADDR(),
50775077
(opline->result_type != IS_UNUSED) ? RES_REG_ADDR() : 0,
50785078
op1_ffi_symbols, op3_ffi_type, ffi_info)) {

0 commit comments

Comments
 (0)