From 07bef6b83c2dc187ef9cf3fc33ded1ea1ac93be4 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 4 Jun 2021 14:57:49 +0100 Subject: [PATCH] coverity: ntp from blob: handle blob missing --- lib/plat/unix/unix-misc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/plat/unix/unix-misc.c b/lib/plat/unix/unix-misc.c index 8dcaaa94c..fce5e4297 100644 --- a/lib/plat/unix/unix-misc.c +++ b/lib/plat/unix/unix-misc.c @@ -127,9 +127,12 @@ lws_plat_ntpclient_config(struct lws_context *context) char *ntpsrv = getenv("LWS_NTP_SERVER"); if (ntpsrv && strlen(ntpsrv) < 64) { - lws_system_blob_direct_set(lws_system_get_blob(context, - LWS_SYSBLOB_TYPE_NTP_SERVER, 0), - (const uint8_t *)ntpsrv, + lws_system_blob_t *blob = lws_system_get_blob(context, + LWS_SYSBLOB_TYPE_NTP_SERVER, 0); + if (!blob) + return 0; + + lws_system_blob_direct_set(blob, (const uint8_t *)ntpsrv, strlen(ntpsrv)); return 1; }