From 168074fe2eddd1e6265c6378af980e165e3dc55d Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Wed, 9 Feb 2022 15:27:22 +0800 Subject: [PATCH] mm/memdump: fix print backtrace abnormal Signed-off-by: Jiuzhu Dong --- mm/mm_heap/mm_memdump.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/mm_heap/mm_memdump.c b/mm/mm_heap/mm_memdump.c index 4cea66d6df..cc99a8e71c 100644 --- a/mm/mm_heap/mm_memdump.c +++ b/mm/mm_heap/mm_memdump.c @@ -77,12 +77,14 @@ static void memdump_handler(FAR struct mm_allocnode_s *node, FAR void *arg) ((FAR char *)node + SIZEOF_MM_ALLOCNODE)); #else int i; + FAR const char *format = " %0*p"; char buf[MM_BACKTRACE_DEPTH * MM_PTR_FMT_WIDTH + 1]; + buf[0] = '\0'; for (i = 0; i < MM_BACKTRACE_DEPTH && node->backtrace[i]; i++) { - sprintf(buf + i * MM_PTR_FMT_WIDTH, " %*p", - MM_PTR_FMT_WIDTH - 3, node->backtrace[i]); + sprintf(buf + i * MM_PTR_FMT_WIDTH, format, + MM_PTR_FMT_WIDTH - 1, node->backtrace[i]); } syslog(LOG_INFO, "%6d%12zu%*p%s\n",