From 8c5142a88594067e8c8ad6eedc4f82ffc15595cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=B1=B3-=E6=A2=85=E5=81=A5?= <62332748+Meissi-jian@users.noreply.github.com> Date: Wed, 17 Jul 2024 00:30:01 +0800 Subject: [PATCH] fix testcase crash on NUTTX When log_buf is null for the first time. (#1844) Signed-off-by: meijian --- tests/convey.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/convey.c b/tests/convey.c index deb88f183..ebe8f4ff7 100644 --- a/tests/convey.c +++ b/tests/convey.c @@ -691,7 +691,9 @@ convey_vlogf(struct convey_log *log, const char *fmt, va_list va, int addnl) if (ptr == NULL) { return; } - memcpy(ptr, log->log_buf, log->log_length); + if (log->log_buf != NULL && log->log_length != 0) { + memcpy(ptr, log->log_buf, log->log_length); + } memset(ptr + log->log_length, 0, newsz - log->log_length); free(log->log_buf); log->log_buf = ptr;