editor: prevent crash on early disconnection

With some really bad luck, it was possible to crash inside
std::string::resize() if the connection was disconnected
right after sending the GET_TRACK command.
This commit is contained in:
Erik Faye-Lund 2010-09-05 00:05:22 +02:00
parent 9da5e1b3d4
commit 126fbe1c33

View File

@ -575,10 +575,11 @@ void processCommand(NetworkSocket &sock)
sock.recv((char *)&strLen, sizeof(int), 0);
clientIndex = ntohl(clientIndex);
strLen = ntohl(strLen);
if (!sock.connected())
return;
trackName.resize(strLen);
sock.recv(&trackName[0], strLen, 0);
if (!sock.connected())
if (!sock.recv(&trackName[0], strLen, 0))
return;
// find track