plat win be robust against NULL wsi_from_fd
authorAndy Green <andy.green@linaro.org>
Fri, 13 Nov 2015 02:14:50 +0000 (10:14 +0800)
committerAndy Green <andy.green@linaro.org>
Fri, 13 Nov 2015 02:14:50 +0000 (10:14 +0800)
After "haitetra"

https://github.com/warmcat/libwebsockets/issues/343

Signed-off-by: Andy Green <andy.green@linaro.org>
lib/lws-plat-win.c

index 122ec84..5295679 100644 (file)
@@ -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);