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-20 09:23:24 +08:00
parent bf6ba0427b
commit e7f9232c1a
4 changed files with 7 additions and 1 deletions

View file

@ -703,7 +703,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

@ -261,6 +261,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

@ -535,6 +535,7 @@ struct lws_context {
void *user_space;
struct lws_plat_file_ops fops;
unsigned int being_destroyed:1;
};
enum {

View file

@ -149,6 +149,9 @@ bail:
int
_lws_rx_flow_control(struct lws *wsi)
{
if (!wsi || wsi->context->being_destroyed)
return 0;
/* there is no pending change */
if (!(wsi->rxflow_change_to & LWS_RXFLOW_PENDING_CHANGE))
return 0;