Skip to content

Commit

Permalink
fix testcase crash on NUTTX When log_buf is null for the first time. (#…
Browse files Browse the repository at this point in the history
…1844)

Signed-off-by: meijian <meijian@xiaomi.com>
  • Loading branch information
Meissi-jian authored Jul 16, 2024
1 parent 603282f commit 8c5142a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/convey.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8c5142a

Please sign in to comment.