From 9893f6461039d6c40e169a5565916be4e4507a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E5=85=89=E4=BC=9F?= Date: Sat, 21 Dec 2019 00:17:38 +0800 Subject: [PATCH] =?UTF-8?q?ulogbuffer=E5=A2=9E=E5=8A=A01=EF=BC=8C=E4=B8=BA?= =?UTF-8?q?\0=E9=A2=84=E7=95=99=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RGW --- components/utilities/ulog/ulog.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index 8a8d142eff..ca356f92f2 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -81,12 +81,12 @@ struct rt_ulog /* all backends */ rt_slist_t backend_list; /* the thread log's line buffer */ - char log_buf_th[ULOG_LINE_BUF_SIZE]; + char log_buf_th[ULOG_LINE_BUF_SIZE + 1]; #ifdef ULOG_USING_ISR_LOG /* the ISR log's line buffer */ rt_base_t output_locker_isr_lvl; - char log_buf_isr[ULOG_LINE_BUF_SIZE]; + char log_buf_isr[ULOG_LINE_BUF_SIZE + 1]; #endif /* ULOG_USING_ISR_LOG */ #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 } /* package newline sign */ log_len += ulog_strcpy(log_len, log_buf + log_len, ULOG_NEWLINE_SIGN); + /*add string end sign*/ + log_buf[log_len] = '\0'; /* do log output */ do_output(LOG_LVL_DBG, NULL, RT_TRUE, log_buf, log_len); }