Browse Source

Bug 1464: Session instance could not be reused for multiple ScanFingerprint calls

https://winscp.net/tracker/1464
(cherry picked from commit 677ff5f00a869a16b15eff646bcea26c7c8b4c79)

Source commit: a248eac60318c6a6998b1192ef18649e476e40f4
Martin Prikryl 9 years ago
parent
commit
1127768f28
1 changed files with 10 additions and 2 deletions
  1. 10 2
      dotnet/Session.cs

+ 10 - 2
dotnet/Session.cs

@@ -114,8 +114,7 @@ namespace WinSCP
             {
                 Timeout = new TimeSpan(0, 1, 0);
                 _reconnectTime = new TimeSpan(0, 2, 0); // keep in sync with TScript::OptionImpl
-                Output = new StringCollection();
-                _error = new StringCollection();
+                ResetOutput();
                 _operationResults = new List<OperationResultBase>();
                 _events = new List<Action>();
                 _eventsEvent = new AutoResetEvent(false);
@@ -127,6 +126,12 @@ namespace WinSCP
             }
         }
 
+        private void ResetOutput()
+        {
+            Output = new StringCollection();
+            _error = new StringCollection();
+        }
+
         public void Dispose()
         {
             using (Logger.CreateCallstackAndLock())
@@ -176,6 +181,7 @@ namespace WinSCP
                 try
                 {
                     SetupTempPath();
+                    ResetOutput();
 
                     _process = ExeSessionProcess.CreateForSession(this);
 
@@ -332,6 +338,8 @@ namespace WinSCP
 
                 try
                 {
+                    ResetOutput();
+
                     string command;
                     string log; // unused
                     SessionOptionsToUrlAndSwitches(sessionOptions, true, out command, out log);