From c023cec697f9235bd6b937dd442876d3d13dcf8e Mon Sep 17 00:00:00 2001 From: Charl Wentzel Date: Mon, 20 Nov 2017 15:32:21 +0200 Subject: [PATCH] Important update: - Bug fix: Error when writing to closed socket --- SelectableCore.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SelectableCore.cpp b/SelectableCore.cpp index e4cea7b..383b1dd 100644 --- a/SelectableCore.cpp +++ b/SelectableCore.cpp @@ -1169,9 +1169,14 @@ bool CSelectableCore::Write( THandle * Handle ) int BytesWritten = 0; // Validate - if (!Handle || (Handle->State == csNone) || (Handle->State == csFailed) || (Handle->State == csClosed)) + if (!Handle) + return false; + + // Is Handle open? + if ((Handle->State == csNone) || (Handle->State == csFailed) || (Handle->State == csClosed)) { - if (Handle->AutoManage) + // May it be opened? + if (Handle && Handle->AutoManage) { // Check duration since last PortIn if (Timeout( Handle->ReopenStart, Handle->ReopenDelay ))