diff options
author | Laurent Rineau <laurent.rineau@cgal.org> | 2017-07-25 17:40:40 +0200 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-08-02 16:13:55 -0400 |
commit | 70272f3c369f74c64bb0a535f5a6eb15253685a4 (patch) | |
tree | d8fa5164e9ec07b4bb6ceab64ba66fbaae18e73d | |
parent | f15cfd891d1e01247ed285320ae32b6c3182ac8f (diff) | |
download | cmake-70272f3c369f74c64bb0a535f5a6eb15253685a4.tar.gz |
server: Fix crash on missing cache entries
Test for nullptr before constructing std::string.
-rw-r--r-- | Source/cmServerProtocol.cxx | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index defba7726f..c5b7f6064a 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 " + |