From 4abc5c1b3ded3c1f2eb409e7e22dc0d0b8293019 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Thu, 26 Jan 2023 08:11:39 +0100 Subject: [PATCH] Reduce crash probability in TSecureShellCmd.Connect when user disconnects from session before tunnel is reestablished. --- source/dbconnection.pas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 2a590f21..3d1634af 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -1090,7 +1090,7 @@ var rx: TRegExpr; StartupInfo: TStartupInfo; ExitCode: LongWord; - Waited, PortChecks: Integer; + Waited, PortChecks, SshTimeOutMilliseconds: Integer; IsPlink: Boolean; begin // Check if local port is open @@ -1163,7 +1163,8 @@ begin // Parse pipe output and probably show some message in a dialog. Waited := 0; DialogTitle := ExtractFileName(FConnection.Parameters.SSHExe); - while Waited < FConnection.Parameters.SSHTimeout*1000 do begin + SshTimeOutMilliseconds := FConnection.Parameters.SSHTimeout * 1000; + while Waited < SshTimeOutMilliseconds do begin Inc(Waited, 200); WaitForSingleObject(FProcessInfo.hProcess, 200); GetExitCodeProcess(FProcessInfo.hProcess, ExitCode);