summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorvvs31415 <vvs31415@users.noreply.github.com>2020-09-05 18:09:04 (GMT)
committerBrad King <brad.king@kitware.com>2020-09-08 16:20:28 (GMT)
commita46fdda46422c4d41afc44a5df02104acfee78ba (patch)
tree9f4110679e3a426bb34016bb34763451e0e0e20a /Source
parent503d0f80e1ccafa8352145b1a733dd41751dcd7f (diff)
downloadCMake-a46fdda46422c4d41afc44a5df02104acfee78ba.zip
CMake-a46fdda46422c4d41afc44a5df02104acfee78ba.tar.gz
CMake-a46fdda46422c4d41afc44a5df02104acfee78ba.tar.bz2
cmGeneratorTarget: Avoid missing nullptr check
Revise logic in `ComputeOutputDir` that was previously missing a check for nullptr before constructing a `std::string`. Fixes: #21165
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorTarget.cxx34
1 files changed, 12 insertions, 22 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index f8568b3..1bb069f 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -6472,21 +6472,16 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
// Look for a target property defining the target output directory
// based on the target type.
std::string targetTypeName = this->GetOutputTargetType(artifact);
- const char* propertyName = nullptr;
- std::string propertyNameStr = targetTypeName;
- if (!propertyNameStr.empty()) {
- propertyNameStr += "_OUTPUT_DIRECTORY";
- propertyName = propertyNameStr.c_str();
+ std::string propertyName;
+ if (!targetTypeName.empty()) {
+ propertyName = cmStrCat(targetTypeName, "_OUTPUT_DIRECTORY");
}
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(conf);
- const char* configProp = nullptr;
- std::string configPropStr = targetTypeName;
- if (!configPropStr.empty()) {
- configPropStr += "_OUTPUT_DIRECTORY_";
- configPropStr += configUpper;
- configProp = configPropStr.c_str();
+ std::string configProp;
+ if (!targetTypeName.empty()) {
+ configProp = cmStrCat(targetTypeName, "_OUTPUT_DIRECTORY_", configUpper);
}
// Select an output directory.
@@ -6547,22 +6542,17 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
{
// Look for a target property defining the target output directory
// based on the target type.
- const char* propertyName = nullptr;
- std::string propertyNameStr = kind;
- if (!propertyNameStr.empty()) {
- propertyNameStr += "_OUTPUT_DIRECTORY";
- propertyName = propertyNameStr.c_str();
+ std::string propertyName;
+ if (!kind.empty()) {
+ propertyName = cmStrCat(kind, "_OUTPUT_DIRECTORY");
}
std::string conf = config;
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(conf);
- const char* configProp = nullptr;
- std::string configPropStr = kind;
- if (!configPropStr.empty()) {
- configPropStr += "_OUTPUT_DIRECTORY_";
- configPropStr += configUpper;
- configProp = configPropStr.c_str();
+ std::string configProp;
+ if (!kind.empty()) {
+ configProp = cmStrCat(kind, "_OUTPUT_DIRECTORY_", configUpper);
}
// Select an output directory.