libc/execinfo/dumpstack: correct the line size to avoid LF overwrite

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-04-15 16:13:37 +08:00 committed by David Sidrane
parent 137eb594cb
commit b2016e85f5

View File

@ -44,7 +44,7 @@
void dump_stack(void)
{
FAR void *address[DUMP_DEPTH];
char line[DUMP_LINESIZE];
char line[DUMP_LINESIZE + 1];
int ret = 0;
int size;
int i;
@ -61,7 +61,7 @@ void dump_stack(void)
DUMP_FORMAT, DUMP_WIDTH, address[i]);
if (i == size - 1 || ret % DUMP_LINESIZE == 0)
{
syslog(LOG_INFO, "[BackTrace]: %s\n", line);
syslog(LOG_INFO, "[CallStack %d]: %s\n", i / DUMP_NITEM, line);
ret = 0;
}
}