From e4916033fa2c4d46891bf5241e0eee792d89455b Mon Sep 17 00:00:00 2001 From: ORelio Date: Mon, 2 Mar 2015 21:35:45 +0100 Subject: [PATCH] Fix crash on disconnect when failed to connect Fix #67 and bug report by doranchak (post no 1084 on forum thread at minecraft forums) --- MinecraftClient/McTcpClient.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 29dc1ab62c..2ba5c7d5c1 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -283,8 +283,11 @@ public void Disconnect() if (bot is ChatBots.Script) scripts_on_hold.Add((ChatBots.Script)bot); - handler.Disconnect(); - handler.Dispose(); + if (handler != null) + { + handler.Disconnect(); + handler.Dispose(); + } if (cmdprompt != null) cmdprompt.Abort();