Przeglądaj źródła

cbcurr can be left behind when session is disconnected while a callback is called

Source commit: 555f30af4ec072eb3ebf40eaaa0f2b9492274b22
Martin Prikryl 6 lat temu
rodzic
commit
9fcc1f7f4a
2 zmienionych plików z 4 dodań i 1 usunięć
  1. 2 1
      source/core/SecureShell.cpp
  2. 2 0
      source/putty/callback.c

+ 2 - 1
source/core/SecureShell.cpp

@@ -1675,7 +1675,8 @@ void __fastcall TSecureShell::FreeBackend()
     sfree(FCallbackSet->ic_pktin_free);
     FCallbackSet->ic_pktin_free = NULL;
 
-    DebugAssert(FCallbackSet->cbcurr == NULL);
+    // Not checking that cbcurr is NULL. It may be non-null, when (fatal?) exception occurs, while the callback is called.
+    FCallbackSet->cbcurr = NULL;
     DebugAssert(FCallbackSet->cbhead == NULL);
     DebugAssert(FCallbackSet->cbtail == NULL);
 

+ 2 - 0
source/putty/callback.c

@@ -138,6 +138,8 @@ bool run_toplevel_callbacks(CALLBACK_SET_ONLY)
          */
         cbcurr->fn(cbcurr->ctx);
         sfree(cbcurr);
+        // WINSCP: this does not happen, when exception (disconnect) occurs while the callback is called.
+        // See also the comment in TSecureShell::FreeBackend().
         cbcurr = NULL;
 
         done_something = true;