prevent GameSend send() call on invalid socket (#240)

prevents WSAENOTSOCK by not allowing a `send()` call on an
invalid/closed socket when the game client isn't connected

---

By creating this pull request, I understand that code that is AI
generated or otherwise automatically generated may be rejected without
further discussion.
I declare that I fully understand all code I pushed into this PR, and
wrote all this code myself and own the rights to this code.
This commit is contained in:
Tixx
2026-08-02 13:53:30 +02:00
committed by GitHub
+4
View File
@@ -51,6 +51,10 @@ int KillSocket(uint64_t Dead) {
} }
void GameSend(std::string_view Data) { void GameSend(std::string_view Data) {
if (!GConnected) {
debug("Tried to call GameSend but socket was not connected. Data: " + std::string(Data));
return;
}
static std::mutex Lock; static std::mutex Lock;
std::scoped_lock Guard(Lock); std::scoped_lock Guard(Lock);
auto ToSend = Utils::PrependHeader<std::string_view>(Data); auto ToSend = Utils::PrependHeader<std::string_view>(Data);