1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

Don't free wsi->u.hdr.ah except through lws_free_header_table (exception: server.c frees 'ah' after copying the header pointer and transitioning the union state).

This commit is contained in:
Andrew Canaday 2014-11-07 11:21:09 +08:00 committed by Andy Green
parent 377188189a
commit a19d485b80
3 changed files with 5 additions and 12 deletions

View file

@ -88,8 +88,7 @@ libwebsocket_close_and_free_session(struct libwebsocket_context *context,
context->protocols[0].callback(context, wsi,
LWS_CALLBACK_CLIENT_CONNECTION_ERROR, wsi->user_space, NULL, 0);
free(wsi->u.hdr.ah);
wsi->u.hdr.ah = NULL;
lws_free_header_table(wsi);
goto just_kill_connection;
}

View file

@ -268,10 +268,7 @@ handshake_0405(struct libwebsocket_context *context, struct libwebsocket *wsi)
bail:
/* free up his parsing allocations */
if (wsi->u.hdr.ah)
free(wsi->u.hdr.ah);
lws_free_header_table(wsi);
return -1;
}

View file

@ -550,9 +550,7 @@ upgrade_ws:
}
/* drop the header info -- no bail_nuke_ah after this */
if (wsi->u.hdr.ah)
free(wsi->u.hdr.ah);
lws_free_header_table(wsi);
wsi->mode = LWS_CONNMODE_WS_SERVING;
@ -589,8 +587,7 @@ upgrade_ws:
bail_nuke_ah:
/* drop the header info */
if (wsi->u.hdr.ah)
free(wsi->u.hdr.ah);
lws_free_header_table(wsi);
return 1;
}
@ -713,7 +710,7 @@ int lws_server_socket_service(struct libwebsocket_context *context,
lwsl_info("lws_server_skt_srv: read 0 len\n");
/* lwsl_info(" state=%d\n", wsi->state); */
if (!wsi->hdr_parsing_completed)
free(wsi->u.hdr.ah);
lws_free_header_table(wsi);
/* fallthru */
case LWS_SSL_CAPABLE_ERROR:
libwebsocket_close_and_free_session(