Kaynağa Gözat

cmLocalGenerator: check variables before usage

Reported by https://pvs-studio.com/en/blog/posts/cpp/1277/ (N2)

Issue: 27159
Marc Chevrier 5 ay önce
ebeveyn
işleme
d614e8fb3f
1 değiştirilmiş dosya ile 2 ekleme ve 3 silme
  1. 2 3
      Source/cmLocalGenerator.cxx

+ 2 - 3
Source/cmLocalGenerator.cxx

@@ -1441,7 +1441,7 @@ void cmLocalGenerator::GetDeviceLinkFlags(
 
 
   auto linklang = linkLineComputer.GetLinkerLanguage(target, config);
   auto linklang = linkLineComputer.GetLinkerLanguage(target, config);
   auto ipoEnabled = target->IsIPOEnabled(linklang, config);
   auto ipoEnabled = target->IsIPOEnabled(linklang, config);
-  if (!ipoEnabled) {
+  if (!ipoEnabled && pcli) {
     ipoEnabled = linkLineComputer.ComputeRequiresDeviceLinkingIPOFlag(*pcli);
     ipoEnabled = linkLineComputer.ComputeRequiresDeviceLinkingIPOFlag(*pcli);
   }
   }
   if (ipoEnabled) {
   if (ipoEnabled) {
@@ -3001,9 +3001,8 @@ void cmLocalGenerator::CopyPchCompilePdb(
   } else {
   } else {
     cc->SetOutputs(outputs);
     cc->SetOutputs(outputs);
     cmSourceFile* copy_rule = this->AddCustomCommandToOutput(std::move(cc));
     cmSourceFile* copy_rule = this->AddCustomCommandToOutput(std::move(cc));
-    copy_rule->SetProperty("CXX_SCAN_FOR_MODULES", "0");
-
     if (copy_rule) {
     if (copy_rule) {
+      copy_rule->SetProperty("CXX_SCAN_FOR_MODULES", "0");
       target->AddSource(copy_rule->ResolveFullPath());
       target->AddSource(copy_rule->ResolveFullPath());
     }
     }
   }
   }