From 3775ac9d2e0ae4127fb1d1fc57b4ba4b7576fe03 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 19 Mar 2018 07:55:01 +0800 Subject: [PATCH] coverity 169270: client: handle NULL protocol --- lib/client/client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/client/client.c b/lib/client/client.c index 29e89e2b..04c9201b 100644 --- a/lib/client/client.c +++ b/lib/client/client.c @@ -876,7 +876,7 @@ lws_client_interpret_server_handshake(struct lws *wsi) n = 0; while (wsi->vhost->protocols[n].callback) { - if (strcmp(wsi->protocol->name, + if (wsi->protocol && strcmp(wsi->protocol->name, wsi->vhost->protocols[n].name) == 0) { wsi->protocol = &wsi->vhost->protocols[n]; break; @@ -885,7 +885,10 @@ lws_client_interpret_server_handshake(struct lws *wsi) } if (!wsi->vhost->protocols[n].callback) { - lwsl_err("Failed to match protocol %s\n", wsi->protocol->name); + if (wsi->protocol) + lwsl_err("Failed to match protocol %s\n", wsi->protocol->name); + else + lwsl_err("No protocol on client\n"); goto bail2; } }