Skip to content

Commit

Permalink
Fix mem leak: If no FClientThread, free FClient ourselves
Browse files Browse the repository at this point in the history
  • Loading branch information
michaliskambi committed Apr 17, 2024
1 parent ec8555c commit 7b7cfb7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/files/indy/castleclientserver.pas
Expand Up @@ -705,6 +705,10 @@ destructor TCastleTCPClient.Destroy;
FClientThread.FreeOnTerminate := true;
FClientThread.Terminate;
FClientThread := nil; // will free itself because FreeOnTerminate = true, so don't keep reference to it
end else
begin
{ If no FClientThread, free FClient ourselves. }
FreeAndNil(FClient);
end;
{$endif}

Expand Down

0 comments on commit 7b7cfb7

Please sign in to comment.