From a9e4c6ace1eb48141c31d8b9a13711e1cdea9481 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 20 Jan 2022 20:05:12 +0800 Subject: [PATCH] libc: backtrace_malloc change sprintf to snprintf since snprintf can handle NULL pointer but sprintf can't. Signed-off-by: Xiang Xiao --- libs/libc/misc/lib_execinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/libc/misc/lib_execinfo.c b/libs/libc/misc/lib_execinfo.c index f963aa760c..422ffad75e 100644 --- a/libs/libc/misc/lib_execinfo.c +++ b/libs/libc/misc/lib_execinfo.c @@ -42,7 +42,7 @@ static FAR char **backtrace_malloc(FAR void *const *buffer, int size) while (size-- > 0) { - int ret = sprintf(NULL, "%pS", *buffer++); + int ret = snprintf(NULL, 0, "%pS", *buffer++); if (ret < 0) { return NULL;