client: avoid possible NULL deref on error path upstream_210817 upstream/1.7.9
authorAndy Green <andy@warmcat.com>
Mon, 12 Dec 2016 12:41:05 +0000 (20:41 +0800)
committerAndy Green <andy@warmcat.com>
Mon, 12 Dec 2016 12:41:05 +0000 (20:41 +0800)
https://github.com/warmcat/libwebsockets/issues/672

lib/client-handshake.c

index f78f4f1..904f6ec 100644 (file)
@@ -311,8 +311,11 @@ 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;
+       if (wsi->u.hdr.ah)
+               wsi->u.hdr.ah->rxpos = wsi->u.hdr.ah->rxlen;
+
        lws_header_table_detach(wsi);
+
        /* take care that we might be inserted in fds already */
        if (wsi->position_in_fds_table != -1)
                goto failed;