From ca30428ceea64e4ae76e0fe3b350107c910b2ef7 Mon Sep 17 00:00:00 2001 From: Tangyuxin <462747508@qq.com> Date: Tue, 27 Sep 2022 11:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=8E=E6=A6=82=E7=8E=87?= =?UTF-8?q?=E7=BB=88=E7=AB=AF=E6=97=A0=E6=B3=95=E8=BE=93=E5=85=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#6464)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [ulog] Fix the problem that the terminal cannot input * [mem] Fix NULL pointer access --- components/utilities/ulog/backend/console_be.c | 4 ---- src/mem.c | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/components/utilities/ulog/backend/console_be.c b/components/utilities/ulog/backend/console_be.c index eb2e14a879..20c87cb2eb 100644 --- a/components/utilities/ulog/backend/console_be.c +++ b/components/utilities/ulog/backend/console_be.c @@ -31,11 +31,7 @@ void ulog_console_backend_output(struct ulog_backend *backend, rt_uint32_t level } else { - rt_uint16_t old_flag = dev->open_flag; - - dev->open_flag |= RT_DEVICE_FLAG_STREAM; rt_device_write(dev, 0, log, len); - dev->open_flag = old_flag; } #else rt_hw_console_output(log); diff --git a/src/mem.c b/src/mem.c index 14593bcfd7..221a5553e6 100644 --- a/src/mem.c +++ b/src/mem.c @@ -525,12 +525,6 @@ void rt_smem_free(void *rmem) /* Get the corresponding struct rt_small_mem_item ... */ mem = (struct rt_small_mem_item *)((rt_uint8_t *)rmem - SIZEOF_STRUCT_MEM); - - RT_DEBUG_LOG(RT_DEBUG_MEM, - ("release memory 0x%x, size: %d\n", - (rt_ubase_t)rmem, - (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr)))); - /* ... which has to be in a used state ... */ small_mem = MEM_POOL(mem); RT_ASSERT(small_mem != RT_NULL); @@ -541,6 +535,11 @@ void rt_smem_free(void *rmem) (rt_uint8_t *)rmem < (rt_uint8_t *)small_mem->heap_end); RT_ASSERT(MEM_POOL(&small_mem->heap_ptr[mem->next]) == small_mem); + RT_DEBUG_LOG(RT_DEBUG_MEM, + ("release memory 0x%x, size: %d\n", + (rt_ubase_t)rmem, + (rt_ubase_t)(mem->next - ((rt_uint8_t *)mem - small_mem->heap_ptr)))); + /* ... and is now unused. */ mem->pool_ptr = MEM_FREED(); #ifdef RT_USING_MEMTRACE