From 46d9b8e06fb4e9b02214ae3714edaf424ba282b0 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 13 Nov 2015 10:14:50 +0800 Subject: [PATCH] plat win be robust against NULL wsi_from_fd After "haitetra" https://github.com/warmcat/libwebsockets/issues/343 Signed-off-by: Andy Green --- lib/lws-plat-win.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/lws-plat-win.c b/lib/lws-plat-win.c index 122ec84c..52956793 100644 --- a/lib/lws-plat-win.c +++ b/lib/lws-plat-win.c @@ -142,6 +142,7 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms) DWORD ev; WSANETWORKEVENTS networkevents; struct libwebsocket_pollfd *pfd; + struct libwebsocket *wsi; /* stay dead once we are dead */ @@ -157,7 +158,8 @@ lws_plat_service(struct libwebsocket_context *context, int timeout_ms) continue; if (pfd->events & LWS_POLLOUT) { - if (wsi_from_fd(context,pfd->fd)->sock_send_blocking) + wsi = wsi_from_fd(context, pfd->fd); + if (!wsi || wsi->sock_send_blocking) continue; pfd->revents = LWS_POLLOUT; n = libwebsocket_service_fd(context, pfd);