From 124424e9974ade26521bf4751f3701c1e7d91c3d Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Thu, 20 Jul 2017 21:18:41 -0600 Subject: server: Protect several fields from potentially pointing to bad memory --- Source/cmConnection.cxx | 5 ++++- Source/cmServerConnection.cxx | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmConnection.cxx b/Source/cmConnection.cxx index 89013dc..c0d1b82 100644 --- a/Source/cmConnection.cxx +++ b/Source/cmConnection.cxx @@ -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; } diff --git a/Source/cmServerConnection.cxx b/Source/cmServerConnection.cxx index e686403..44af75f 100644 --- a/Source/cmServerConnection.cxx +++ b/Source/cmServerConnection.cxx @@ -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); -- cgit v0.12