mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-08-27 04:37:41 +00:00
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:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user