summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorR2RT <artur.ryt@gmail.com>2018-04-08 20:56:44 (GMT)
committerBrad King <brad.king@kitware.com>2018-04-09 15:59:07 (GMT)
commitaad360eb3d07fc34048f3065e2d3617fa07f2932 (patch)
tree8149a890d1e37916ab34deaeeedf9beb541c4fa5 /Source/cmMakefile.cxx
parent61fd4c742013a7f9139db190f936703b656540ff (diff)
downloadCMake-aad360eb3d07fc34048f3065e2d3617fa07f2932.zip
CMake-aad360eb3d07fc34048f3065e2d3617fa07f2932.tar.gz
CMake-aad360eb3d07fc34048f3065e2d3617fa07f2932.tar.bz2
Fix crash with --trace-expand --warn-uninitialized together
Some code paths in `ExpandVariablesInString{New,Old}` were not checking the `filename` parameter for a null pointer, but this can happen when using the above flags together. Add the checks and a test case. Fixes: #17896
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index b468208..71359a2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2679,10 +2679,11 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if (this->GetCMakeInstance()->GetWarnUninitialized() &&
!this->VariableInitialized(lookup)) {
if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(filename,
- this->GetHomeDirectory()) ||
- cmSystemTools::IsSubDirectory(
- filename, this->GetHomeOutputDirectory())) {
+ (filename &&
+ (cmSystemTools::IsSubDirectory(filename,
+ this->GetHomeDirectory()) ||
+ cmSystemTools::IsSubDirectory(
+ filename, this->GetHomeOutputDirectory())))) {
std::ostringstream msg;
msg << "uninitialized variable \'" << lookup << "\'";
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());