Browse Source

cmComputeTargetDepends: Add missing nullptr check

Check the result of `GetLinkImplementation` before using it.
Brad King 5 years ago
parent
commit
7695b67500
1 changed files with 9 additions and 7 deletions
  1. 9 7
      Source/cmComputeTargetDepends.cxx

+ 9 - 7
Source/cmComputeTargetDepends.cxx

@@ -198,16 +198,18 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
     std::vector<std::string> const& configs =
       depender->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
     for (std::string const& it : configs) {
-      cmLinkImplementation const* impl = depender->GetLinkImplementation(it);
-
       // A target should not depend on itself.
       emitted.insert(cmLinkItem(depender, false, cmListFileBacktrace()));
       emitted.insert(cmLinkItem(depender, true, cmListFileBacktrace()));
-      for (cmLinkImplItem const& lib : impl->Libraries) {
-        // Don't emit the same library twice for this target.
-        if (emitted.insert(lib).second) {
-          this->AddTargetDepend(depender_index, lib, true, false);
-          this->AddInterfaceDepends(depender_index, lib, it, emitted);
+
+      if (cmLinkImplementation const* impl =
+            depender->GetLinkImplementation(it)) {
+        for (cmLinkImplItem const& lib : impl->Libraries) {
+          // Don't emit the same library twice for this target.
+          if (emitted.insert(lib).second) {
+            this->AddTargetDepend(depender_index, lib, true, false);
+            this->AddInterfaceDepends(depender_index, lib, it, emitted);
+          }
         }
       }