server: Protect several fields from potentially pointing to bad memory

This commit is contained in:
Justin Berger
2017-07-20 21:18:41 -06:00
committed by Brad King
parent 693fa0a96e
commit 124424e997
2 changed files with 7 additions and 1 deletions

View File

@@ -118,7 +118,9 @@ void cmEventBasedConnection::OnDisconnect(int onerror)
{
(void)onerror;
this->OnConnectionShuttingDown();
this->Server->OnDisconnect(this);
if (this->Server) {
this->Server->OnDisconnect(this);
}
}
cmConnection::~cmConnection()
@@ -127,6 +129,7 @@ cmConnection::~cmConnection()
bool cmConnection::OnConnectionShuttingDown()
{
this->Server = nullptr;
return true;
}

View File

@@ -53,6 +53,9 @@ void cmStdIoConnection::SetupStream(uv_stream_t*& stream, int file_id)
void cmStdIoConnection::SetServer(cmServerBase* s)
{
cmConnection::SetServer(s);
if (!s) {
return;
}
SetupStream(this->ReadStream, 0);
SetupStream(this->WriteStream, 1);