From 363c644730198338140d9611b575ff22e14e1287 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 15 Oct 2020 20:58:18 -0700 Subject: [PATCH] service: bcat: Check client connection before interacting with socket. - Fixes a crash when BCAT service is offline. --- src/core/hle/service/bcat/backend/boxcat.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/hle/service/bcat/backend/boxcat.cpp b/src/core/hle/service/bcat/backend/boxcat.cpp index 589e288df..3b6f7498e 100644 --- a/src/core/hle/service/bcat/backend/boxcat.cpp +++ b/src/core/hle/service/bcat/backend/boxcat.cpp @@ -454,6 +454,16 @@ Boxcat::StatusResult Boxcat::GetStatus(std::optional& global, {std::string("Boxcat-Client-Type"), std::string(BOXCAT_CLIENT_TYPE)}, }; + if (!client.is_valid()) { + LOG_ERROR(Service_BCAT, "Client is invalid, going offline!"); + return StatusResult::Offline; + } + + if (!client.is_socket_open()) { + LOG_ERROR(Service_BCAT, "Failed to open socket, going offline!"); + return StatusResult::Offline; + } + const auto response = client.Get(BOXCAT_PATHNAME_EVENTS, headers); if (response == nullptr) return StatusResult::Offline;