diff options
| author | yi chen <[email protected]> | 2026-07-09 11:48:03 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2026-07-16 13:31:55 +0800 |
| commit | 2835e956e87195a25f83e57de54362bd8e537775 (patch) | |
| tree | 4a37dd33838d6707e0b9a86b2e4139dcd3525a77 /src | |
| parent | 414ff7f3710168dbf99a398e18b2a4ff8448b005 (diff) | |
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 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/mem.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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; |
