From bfc8a5cb1bd0129fe2a847229dc96ccd75c8e9c9 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 19 Mar 2018 08:04:02 +0800 Subject: [PATCH] coverity 188325: client: require at least once vhost --- lib/client/client-handshake.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/client/client-handshake.c b/lib/client/client-handshake.c index 984d710e..70e33781 100644 --- a/lib/client/client-handshake.c +++ b/lib/client/client-handshake.c @@ -771,6 +771,12 @@ lws_client_connect_via_info(struct lws_client_connect_info *i) if (!wsi->vhost) wsi->vhost = i->context->vhost_list; + if (!wsi->vhost) { + lwsl_err("At least one vhost in the context is required\n"); + + goto bail; + } + wsi->protocol = &wsi->vhost->protocols[0]; /* @@ -783,7 +789,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i) * which protocol we are associated with since we can give it a * list. */ - if ((i->method || i->local_protocol_name) && wsi->vhost && local) { + if ((i->method || i->local_protocol_name) && local) { lwsl_info("binding to %s\n", local); p = lws_vhost_name_to_protocol(wsi->vhost, local); if (p)