From b75680a15fb7343c2f2db58a5427785a788dce5e Mon Sep 17 00:00:00 2001 From: Andy Green Date: Mon, 12 Dec 2016 20:39:03 +0800 Subject: [PATCH] client: avoid possible NULL deref on error path https://github.com/warmcat/libwebsockets/issues/672 --- lib/client-handshake.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 57a9343f..ca238a1f 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -295,8 +295,9 @@ lws_client_connect_2(struct lws *wsi) oom4: /* we're closing, losing some rx is OK */ - wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen; - //lwsl_err("%d\n", wsi->mode); + if (wsi->u.hdr.ah) + wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen; + if (wsi->mode == LWSCM_HTTP_CLIENT) wsi->vhost->protocols[0].callback(wsi, LWS_CALLBACK_CLIENT_CONNECTION_ERROR,