Bläddra i källkod

PortForwarding minor changes
Apply 13243 with minor changes

olegkap_cp 13 år sedan
förälder
incheckning
ba39209723

+ 4 - 1
Renci.SshClient/Renci.SshNet/ForwardedPort.cs

@@ -57,7 +57,10 @@ namespace Renci.SshNet
         /// </summary>
         public virtual void Stop()
         {
-            this.Session.ErrorOccured -= Session_ErrorOccured;
+            if (this.Session != null)
+            {
+                this.Session.ErrorOccured -= Session_ErrorOccured;
+            }
         }
 
         /// <summary>

+ 2 - 0
Renci.SshClient/Renci.SshNet/ForwardedPortLocal.cs

@@ -122,6 +122,8 @@ namespace Renci.SshNet
             // Check to see if Dispose has already been called.
             if (!this._isDisposed)
             {
+                this.InternalStop();
+
                 // If disposing equals true, dispose all managed
                 // and unmanaged ResourceMessages.
                 if (disposing)

+ 2 - 2
Renci.SshClient/Renci.SshNet/Session.NET.cs

@@ -67,10 +67,10 @@ namespace Renci.SshNet
 
                 buffer.Add(data[0]);
             }
-            while (!(buffer.Count > 1 && (buffer[buffer.Count - 1] == 0x0A || buffer[buffer.Count - 1] == 0x00)));
+            while (!(buffer.Count > 0 && (buffer[buffer.Count - 1] == 0x0A || buffer[buffer.Count - 1] == 0x00)));
 
             // Return an empty version string if the buffer consists of a 0x00 character.
-            if (buffer[buffer.Count - 1] == 0x00)
+            if (buffer.Count > 0 && buffer[buffer.Count - 1] == 0x00)
             {
                 response = string.Empty;
             }