From cbf6b641c23c78b6f82dfb51fecebd0f95a60896 Mon Sep 17 00:00:00 2001 From: Shell Date: Mon, 26 Aug 2024 11:02:18 +0800 Subject: [PATCH] feat: add memset zero for rt_thread_init `rt_object_allocate()` will clear memory after new rt_thread allocate in `rt_thread_create()`. However, in `rt_thread_init()` the same behavior is missing, which corrupt the consistence of the API. Changes: - Added `memset()` zero for `rt_thread_init()` in the entry Signed-off-by: Shell --- src/thread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/thread.c b/src/thread.c index 1327c47bbb..eef7a15376 100644 --- a/src/thread.c +++ b/src/thread.c @@ -334,6 +334,9 @@ rt_err_t rt_thread_init(struct rt_thread *thread, RT_ASSERT(stack_start != RT_NULL); RT_ASSERT(tick != 0); + /* clean memory data of thread */ + rt_memset(thread, 0x0, sizeof(struct rt_thread)); + /* initialize thread object */ rt_object_init((rt_object_t)thread, RT_Object_Class_Thread, name);