diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp index c7b4217e4..9b2fd344f 100644 --- a/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp +++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/GdbServer.cpp @@ -1441,9 +1441,11 @@ void GdbServer::GdbServerLoop() { Acceptor->async_accept([this](fasio::error ec, std::optional Socket) { if (ec != fasio::error::success) { // Listen socket error or shutting down - LogMan::Msg::EFmt("[GdbServer] gdbserver shutting down: {}"); - close(CommsSocket->FD); - CommsSocket.reset(); + if (CommsSocket) { + LogMan::Msg::EFmt("[GdbServer] gdbserver shutting down: {}", CommsSocket->FD); + close(CommsSocket->FD); + CommsSocket.reset(); + } // Repeat to wait for another connection return fasio::post_callback::repeat; }