From 9751cccf0de920cfbca5604b3c8b54c1af254745 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sat, 2 Feb 2019 22:39:47 +0000 Subject: [PATCH] Windows: Fix possible crash when client disconnects. Closes #1137. Thanks to Kris Mattheus. --- ChangeLog.txt | 1 + src/websockets.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 46e45e39..f4a9ddcf 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -33,6 +33,7 @@ Broker: - Allow broker to always restart on Windows when using `log_dest file`. Closes #1080. - Fix Will not being sent for Websockets clients. Closes #1143. +- Windows: Fix possible crash when client disconnects. Closes #1137. Library: - Fix TLS connections not working over SOCKS. diff --git a/src/websockets.c b/src/websockets.c index 163c222e..4db2e8df 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -247,7 +247,7 @@ static int callback_mqtt(struct libwebsocket_context *context, } mosq = u->mosq; if(mosq){ - if(mosq->sock > 0){ + if(mosq->sock != INVALID_SOCKET){ HASH_DELETE(hh_sock, db->contexts_by_sock, mosq); mosq->sock = INVALID_SOCKET; mosq->pollfd_index = -1;