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

avoid using deallocated things during context dedtroy

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-01-18 11:49:41 +08:00
parent 4319b4d78d
commit 9a9d5eaeeb
4 changed files with 6 additions and 2 deletions

View file

@ -785,7 +785,7 @@ check_accept:
p = lws_hdr_simple_ptr(wsi, WSI_TOKEN_ACCEPT);
if (strcmp(p, wsi->u.hdr.ah->initial_handshake_hash_base64)) {
lwsl_warn("lws_client_int_s_hs: accept %s wrong vs %s\n", p,
lwsl_warn("lws_client_int_s_hs: accept '%s' wrong vs '%s'\n", p,
wsi->u.hdr.ah->initial_handshake_hash_base64);
goto bail2;
}

View file

@ -296,6 +296,8 @@ lws_context_destroy(struct lws_context *context)
if (!context)
return;
context->being_destroyed = 1;
memset(&wsi, 0, sizeof(wsi));
wsi.context = context;

View file

@ -600,6 +600,8 @@ struct lws_context {
short max_http_header_data;
short max_http_header_pool;
short ah_count_in_use;
unsigned int being_destroyed:1;
};
enum {

View file

@ -152,7 +152,7 @@ _lws_server_listen_accept_flow_control(struct lws_context *context, int on)
struct lws *wsi = context->wsi_listening;
int n;
if (!wsi)
if (!wsi || context->being_destroyed)
return 0;
lwsl_debug("%s: wsi %p: state %d\n", __func__, (void *)wsi, on);