Skip to content

Commit 20d1c13

Browse files
authored
Merge pull request #3287 from rgw5267/fix_ulog
ulogbuffer增加1,为\0预留空间
2 parents dd23a36 + 9893f64 commit 20d1c13

File tree

1 file changed

+4
-2
lines changed
  • components/utilities/ulog

1 file changed

+4
-2
lines changed

components/utilities/ulog/ulog.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ struct rt_ulog
8181
/* all backends */
8282
rt_slist_t backend_list;
8383
/* the thread log's line buffer */
84-
char log_buf_th[ULOG_LINE_BUF_SIZE];
84+
char log_buf_th[ULOG_LINE_BUF_SIZE + 1];
8585

8686
#ifdef ULOG_USING_ISR_LOG
8787
/* the ISR log's line buffer */
8888
rt_base_t output_locker_isr_lvl;
89-
char log_buf_isr[ULOG_LINE_BUF_SIZE];
89+
char log_buf_isr[ULOG_LINE_BUF_SIZE + 1];
9090
#endif /* ULOG_USING_ISR_LOG */
9191

9292
#ifdef ULOG_USING_ASYNC_OUTPUT
@@ -728,6 +728,8 @@ void ulog_hexdump(const char *tag, rt_size_t width, rt_uint8_t *buf, rt_size_t s
728728
}
729729
/* package newline sign */
730730
log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN);
731+
/*add string end sign*/
732+
log_buf[log_len] = '\0';
731733
/* do log output */
732734
do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len);
733735
}

0 commit comments

Comments
 (0)