summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionNode.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-05 13:04:30 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-05 13:06:00 (GMT)
commitf6fd0abc5bbfa7d677cd090ba8e2894d96afdde8 (patch)
tree2deeea75b706ea1103e1903c228e155978975c26 /Source/cmGeneratorExpressionNode.cxx
parentf6428725bb0ae7e64866e3eca16a5ad8f007f916 (diff)
downloadCMake-f6fd0abc5bbfa7d677cd090ba8e2894d96afdde8.zip
CMake-f6fd0abc5bbfa7d677cd090ba8e2894d96afdde8.tar.gz
CMake-f6fd0abc5bbfa7d677cd090ba8e2894d96afdde8.tar.bz2
Genex: Diagnose invalid LINK_ONLY usage instead of crashing
When `$<LINK_ONLY:...>` is used outside of linking we may evaluate it without a `dagChecker`. Do not dereference the NULL pointer and issue a diagnostic instead. Closes: #16287
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 44e9ce1..c19a741 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -672,15 +672,20 @@ static const struct LinkOnlyNode : public cmGeneratorExpressionNode
LinkOnlyNode() {}
std::string Evaluate(const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* dagChecker) const
CM_OVERRIDE
{
+ if (!dagChecker) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<LINK_ONLY:...> may only be used for linking");
+ return std::string();
+ }
if (!dagChecker->GetTransitivePropertiesOnly()) {
return parameters.front();
}
- return "";
+ return std::string();
}
} linkOnlyNode;