From 70272f3c369f74c64bb0a535f5a6eb15253685a4 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 25 Jul 2017 17:40:40 +0200 Subject: server: Fix crash on missing cache entries Test for nullptr before constructing std::string. --- Source/cmServerProtocol.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index defba77..c5b7f60 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -284,7 +284,9 @@ static bool testValue(cmState* state, const std::string& key, std::string& value, const std::string& keyDescription, std::string* errorMessage) { - const std::string cachedValue = std::string(state->GetCacheEntryValue(key)); + const char* entry = state->GetCacheEntryValue(key); + const std::string cachedValue = + entry == nullptr ? std::string() : std::string(entry); if (!cachedValue.empty() && !value.empty() && cachedValue != value) { setErrorMessage(errorMessage, std::string("\"") + key + "\" is set but incompatible with configured " + -- cgit v0.12