summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Rineau <laurent.rineau@cgal.org>2017-07-25 15:40:40 (GMT)
committerBrad King <brad.king@kitware.com>2017-08-02 20:13:55 (GMT)
commit70272f3c369f74c64bb0a535f5a6eb15253685a4 (patch)
treed8fa5164e9ec07b4bb6ceab64ba66fbaae18e73d
parentf15cfd891d1e01247ed285320ae32b6c3182ac8f (diff)
downloadCMake-70272f3c369f74c64bb0a535f5a6eb15253685a4.zip
CMake-70272f3c369f74c64bb0a535f5a6eb15253685a4.tar.gz
CMake-70272f3c369f74c64bb0a535f5a6eb15253685a4.tar.bz2
server: Fix crash on missing cache entries
Test for nullptr before constructing std::string.
-rw-r--r--Source/cmServerProtocol.cxx4
1 files changed, 3 insertions, 1 deletions
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 " +