diff mbox series

Fix coverity #292141

Message ID 20200419193104.22351-5-sbabic@denx.de
State Accepted
Headers show
Series Fix coverity #292141 | expand

Commit Message

Stefano Babic April 19, 2020, 7:31 p.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 core/util.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/core/util.c b/core/util.c
index 35376f3..8c2a80b 100644
--- a/core/util.c
+++ b/core/util.c
@@ -774,6 +774,7 @@  char *swupdate_time_iso8601(void)
 	char msbuf[4];
 	/* date length is fix, reserve enough space */
 	char *buf = (char *)malloc(DATE_SIZE_ISO8601);
+	char *tmp;
 
 	if (!buf)
 		return NULL;
@@ -787,7 +788,9 @@  char *swupdate_time_iso8601(void)
 	 * Replace '*' placeholder with ms value
 	 */
 	snprintf(msbuf, sizeof(msbuf), "%03d", ms);
-	memcpy(strchr(buf, '*'), msbuf, 3);
+	tmp = strchr(buf, '*');
+	if (tmp)
+		memcpy(tmp, msbuf, 3);
 
 	/*
 	 * strftime add 4 bytes for timezone, ISO8601 uses