diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c index 33bdb895..3c130469 100755 --- a/lib/libwebsockets.c +++ b/lib/libwebsockets.c @@ -432,7 +432,8 @@ just_kill_connection: lws_remove_from_timeout_list(wsi); /* checking return redundant since we anyway close */ - remove_wsi_socket_from_fds(wsi); + if (wsi->sock != LWS_SOCK_INVALID) + remove_wsi_socket_from_fds(wsi); #if defined(LWS_WITH_ESP8266) espconn_disconnect(wsi->sock);