Browse Source

Avoid NRE when disposing.

drieseng 9 years ago
parent
commit
76fdef9d72
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/Renci.SshNet/Sftp/SftpSession.cs

+ 3 - 2
src/Renci.SshNet/Sftp/SftpSession.cs

@@ -315,10 +315,11 @@ namespace Renci.SshNet.Sftp
 
             if (disposing)
             {
-                if (_sftpVersionConfirmed != null)
+                var sftpVersionConfirmed = _sftpVersionConfirmed;
+                if (sftpVersionConfirmed != null)
                 {
-                    _sftpVersionConfirmed.Dispose();
                     _sftpVersionConfirmed = null;
+                    sftpVersionConfirmed.Dispose();
                 }
             }
         }