From ec7bfcbfd6f1c499de1c6aa0fb1c2e2fc00c2460 Mon Sep 17 00:00:00 2001 From: yi chen <94xhn1@gmail.com> Date: Thu, 9 Jul 2026 11:48:03 +0800 Subject: [PATCH] mem: guard rt_smem_setname() against a NULL name rt_smem_setname() dereferenced name[index] without checking for NULL first. Some callers legitimately pass an unnamed allocation through with a NULL name, which crashed instead of just leaving the trace field blank. Treat a NULL name the same as an empty string, so the existing fill-with-spaces loop below handles it without duplicating that logic. Fixes #9793 Signed-off-by: yi chen <94xhn1@gmail.com> --- src/mem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mem.c b/src/mem.c index ce5a87b5fde..1d8c9990408 100644 --- a/src/mem.c +++ b/src/mem.c @@ -103,6 +103,11 @@ struct rt_small_mem rt_inline void rt_smem_setname(struct rt_small_mem_item *mem, const char *name) { int index; + if (name == RT_NULL) + { + name = ""; + } + for (index = 0; index < sizeof(mem->thread); index ++) { if (name[index] == '\0') break;