瀏覽代碼

server: fix crash if no min version specified

If a CMakeLists.txt file doesn't contain cmake_minimum_required then the
server was crashing. The root cause was the json object model does not
support null and was crashing. Add the null check and use an empty
string in this case.
Justin Goshi 7 年之前
父節點
當前提交
33802b3168
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      Source/cmServerProtocol.cxx

+ 2 - 2
Source/cmServerProtocol.cxx

@@ -1034,8 +1034,8 @@ static Json::Value DumpProjectList(const cmake* cm, std::string const& config)
 
 
     // Project structure information:
     // Project structure information:
     const cmMakefile* mf = lg->GetMakefile();
     const cmMakefile* mf = lg->GetMakefile();
-    pObj[kMINIMUM_CMAKE_VERSION] =
-      mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+    auto minVersion = mf->GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION");
+    pObj[kMINIMUM_CMAKE_VERSION] = minVersion ? minVersion : "";
     pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory();
     pObj[kSOURCE_DIRECTORY_KEY] = mf->GetCurrentSourceDirectory();
     pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory();
     pObj[kBUILD_DIRECTORY_KEY] = mf->GetCurrentBinaryDirectory();
     pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config);
     pObj[kTARGETS_KEY] = DumpTargetsList(projectIt.second, config);