From c491cb1eb4030d70e7a04bcda5021ebd0e5ca88d Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 23 Jun 2014 09:34:38 -0400 Subject: [PATCH] Fix some generator crashes on undefined CMAKE_BUILD_TYPE Since commit 84fdc9921 (stringapi: Pass configuration names as strings, 2014-02-09), it is not safe to use GetDefinition("CMAKE_BUILD_TYPE") without checking the return value. Use GetSafeDefinition instead so that a missing definition is treated as an empty string like code paths did prior to the above commit. Reported-by: Richard Wirth --- Source/cmExtraCodeBlocksGenerator.cxx | 2 +- Source/cmExtraEclipseCDT4Generator.cxx | 2 +- Source/cmLocalGenerator.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 6f76dc492..56a6edbbd 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -574,7 +574,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, } } - const char* buildType = makefile->GetDefinition("CMAKE_BUILD_TYPE"); + std::string buildType = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::string location; if ( target->GetType()==cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index e23551e9f..1beb3fd11 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -968,7 +968,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const continue; } std::vector includeDirs; - const char *config = mf->GetDefinition("CMAKE_BUILD_TYPE"); + std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); (*it)->GetIncludeDirectories(includeDirs, l->second, "C", config); this->AppendIncludeDirectories(fout, includeDirs, emmited); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8ae1157ee..abfc3ed0c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1861,7 +1861,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, ((useWatcomQuote) ? WATCOMQUOTE : SHELL); bool escapeAllowMakeVars = !forResponseFile; cmOStringStream fout; - const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); + std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); if(!pcli) {