From 47a56208f0902ecb95d879197a7ed9a3ca9a7e61 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Wed, 28 Oct 2020 10:47:23 +0300 Subject: [PATCH] Fixed memory leak in Zend/tests/bug78999.phpt --- ext/opcache/jit/zend_jit_trace.c | 8 ++++---- ext/opcache/jit/zend_jit_x86.dasc | 19 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ext/opcache/jit/zend_jit_trace.c b/ext/opcache/jit/zend_jit_trace.c index a559b6fa29..45d9e4cd71 100644 --- a/ext/opcache/jit/zend_jit_trace.c +++ b/ext/opcache/jit/zend_jit_trace.c @@ -4623,11 +4623,11 @@ static const void *zend_jit_trace(zend_jit_trace_rec *trace_buffer, uint32_t par info = zend_jit_trace_type_to_info_ex(type, info); if (opline->op1_type == IS_CV && EX_VAR_TO_NUM(opline->op1.var) == j - && !(op1_info & MAY_BE_REF) - && JIT_G(current_frame)) { - if (TRACE_FRAME_IS_RETURN_VALUE_USED(JIT_G(current_frame))) { + && !(op1_info & (MAY_BE_REF|MAY_BE_OBJECT))) { + if (JIT_G(current_frame) + && TRACE_FRAME_IS_RETURN_VALUE_USED(JIT_G(current_frame))) { continue; - } else if ((op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != MAY_BE_OBJECT) { + } else { info |= MAY_BE_NULL; } } diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index d2d5f7eaf5..312c858792 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -11361,17 +11361,14 @@ static int zend_jit_return(dasm_State **Dst, const zend_op *opline, const zend_o op1_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0); } | ZVAL_COPY_VALUE ret_addr, MAY_BE_ANY, op1_addr, op1_info, ZREG_R0, ZREG_R2 - if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || (op1_info & MAY_BE_REF) || (return_value_used != 1)) { - if (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { - if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE - && !(op1_info & MAY_BE_REF) - && op_array->function_name - && (op1_info & (MAY_BE_ANY|MAY_BE_UNDEF)) != MAY_BE_OBJECT) { - | // if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) ZVAL_NULL(retval_ptr); - | SET_ZVAL_TYPE_INFO op1_addr, IS_NULL - } else { - | TRY_ADDREF op1_info, ah, r2 - } + if (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) { + if (JIT_G(trigger) != ZEND_JIT_ON_HOT_TRACE || + (op1_info & (MAY_BE_REF|MAY_BE_OBJECT)) || + !op_array->function_name) { + | TRY_ADDREF op1_info, ah, r2 + } else if (return_value_used != 1) { + | // if (EXPECTED(!(EX_CALL_INFO() & ZEND_CALL_CODE))) ZVAL_NULL(retval_ptr); + | SET_ZVAL_TYPE_INFO op1_addr, IS_NULL } } } else { -- 2.40.0