libc: backtrace_malloc change sprintf to snprintf

since snprintf can handle NULL pointer but sprintf can't.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-01-20 20:05:12 +08:00 committed by Petro Karashchenko
parent 0a1a1e9b79
commit a9e4c6ace1

View File

@ -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;