Fix bug #8170: Crash when client disconnects unexpectedly

When the socket does not exist anymore, we should not try to access it. In
trying to do so, std::map will create a new shared_ptr but this pointer
doesn't point at anything. To prevent this, we explicitly check whether
the socket is available.
This commit is contained in:
Vincent van Ravesteijn 2012-05-24 13:55:41 +02:00
parent 3476a6f1d4
commit 4c3a97d96e

View File

@ -125,8 +125,10 @@ void ServerSocket::serverCallback()
// if the connection has been closed // if the connection has been closed
void ServerSocket::dataCallback(int fd) void ServerSocket::dataCallback(int fd)
{ {
shared_ptr<LyXDataSocket> client = clients[fd]; map<int, shared_ptr<LyXDataSocket> >::const_iterator it = clients.find(fd);
if (it == clients.end())
return;
shared_ptr<LyXDataSocket> client = it->second;
string line; string line;
size_t pos; size_t pos;
bool saidbye = false; bool saidbye = false;