diff options
author | Brad King <brad.king@kitware.com> | 2019-05-22 13:56:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-05-22 14:19:41 (GMT) |
commit | 5a1af142f120ccc6834efcf786e346b06e0f05c6 (patch) | |
tree | db0c47f60d4126ea729d6bf2ff5fbde2004eb7ab /Source/cmGeneratorExpressionNode.cxx | |
parent | 01b6a2c4ee8930e60459b46b4d751148ce28d5a9 (diff) | |
download | CMake-5a1af142f120ccc6834efcf786e346b06e0f05c6.zip CMake-5a1af142f120ccc6834efcf786e346b06e0f05c6.tar.gz CMake-5a1af142f120ccc6834efcf786e346b06e0f05c6.tar.bz2 |
Genex: Fix value lifetimes in nested TARGET_PROPERTY evaluation
For special properties like `INCLUDE_DIRECTORIES`, the pointer returned
by `cmTarget::GetProperty` is only valid until the next time the same
special property is queried on *any* target. When evaluating a nested
`TARGET_PROPERTY` generator expression we may look up such a property
more than once on different targets. Fix `TargetPropertyNode::Evaluate`
to store the lookup result in locally owned memory earlier.
Fixes: #19286
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 709355a..68ef170 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1215,7 +1215,12 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode break; } - const char* prop = target->GetProperty(propertyName); + std::string prop; + bool haveProp = false; + if (const char* p = target->GetProperty(propertyName)) { + prop = p; + haveProp = true; + } if (dagCheckerParent) { if (dagCheckerParent->EvaluatingGenexExpression() || @@ -1235,7 +1240,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } #undef TRANSITIVE_PROPERTY_COMPARE - if (!prop) { + if (!haveProp) { return std::string(); } } else { @@ -1291,7 +1296,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - if (!prop) { + if (!haveProp) { if (target->IsImported() || target->GetType() == cmStateEnums::INTERFACE_LIBRARY) { return linkedTargetsContent; |