From bf6ba0427bc361e702478fddf9273b92d77d6987 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 20 Jan 2016 09:21:03 +0800 Subject: [PATCH] remove double free attempts from no ACCEPT server response cleanup path The generic wsi close code is smart enough to clean up after these allocations itself Signed-off-by: Andy Green --- lib/client.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/client.c b/lib/client.c index af80e276a..b54d0a8e7 100644 --- a/lib/client.c +++ b/lib/client.c @@ -503,18 +503,18 @@ lws_client_interpret_server_handshake(struct lws *wsi) * Now let's confirm it sent all the necessary headers */ - if (lws_hdr_total_length(wsi, WSI_TOKEN_ACCEPT) == 0) { - lwsl_info("no ACCEPT\n"); - p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP); - isErrorCodeReceived = 1; - goto bail3; - } - p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_HTTP); if (!p) { lwsl_info("no URI\n"); goto bail3; } + + if (lws_hdr_total_length(wsi, WSI_TOKEN_ACCEPT) == 0) { + lwsl_info("no ACCEPT\n"); + isErrorCodeReceived = 1; + goto bail3; + } + if (p && strncmp(p, "101", 3)) { lwsl_warn( "lws_client_handshake: got bad HTTP response '%s'\n", p); @@ -790,7 +790,6 @@ check_accept: return 0; bail3: - lws_free_set_NULL(wsi->u.ws.rx_user_buffer); close_reason = LWS_CLOSE_STATUS_NOSTATUS; bail2: @@ -809,8 +808,7 @@ bail2: lwsl_info("closing connection due to bail2 connection error\n"); - /* free up his parsing allocations */ - lws_free_set_NULL(wsi->u.hdr.ah); + /* closing will free up his parsing allocations */ lws_close_free_wsi(wsi, close_reason); return 1;