Browse Source

Dereference socket instance field before disposing it.

drieseng 9 years ago
parent
commit
97ed0ddb1c
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

+ 3 - 2
src/Renci.SshNet/Channels/ChannelDirectTcpip.cs

@@ -263,10 +263,11 @@ namespace Renci.SshNet.Channels
                 {
                     lock (_socketLock)
                     {
-                        if (_socket != null)
+                        var socket = _socket;
+                        if (socket != null)
                         {
-                            _socket.Dispose();
                             _socket = null;
+                            socket.Dispose();
                         }
                     }
                 }