From 8cec96270b2afea0144eb43d0d59957ec84487bf Mon Sep 17 00:00:00 2001 From: Angen Date: Mon, 14 Mar 2022 17:19:42 +0000 Subject: [PATCH] Don't create thread on failed connection Differential revision: D4545 Fixes: #6442 This was SVN commit r26649. --- source/network/NetClient.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index b14e4eb7a9..a9541fcf1e 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 Wildfire Games. +/* Copyright (C) 2022 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -201,7 +201,8 @@ bool CNetClient::SetupConnection(ENetHost* enetClient) CNetClientSession* session = new CNetClientSession(*this); bool ok = session->Connect(m_ServerAddress, m_ServerPort, enetClient); SetAndOwnSession(session); - m_PollingThread = std::thread(Threading::HandleExceptions::Wrapper, m_Session); + if (ok) + m_PollingThread = std::thread(Threading::HandleExceptions::Wrapper, m_Session); return ok; }