From c2cceee8449e6d2574ea5dda0c3e1ecbfe8e74d7 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 2 Mar 2022 22:17:00 +0200 Subject: [PATCH] QmakePM: Fix potential null dereference Reported by Coverity. Change-Id: Ibdb47a711aca4989b22a7f94fd905deff86cb27c Reviewed-by: Christian Kandeler --- .../qmakeprojectmanager/librarydetailscontroller.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp index 6a1e405b369..d8deb72b77e 100644 --- a/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp +++ b/src/plugins/qmakeprojectmanager/librarydetailscontroller.cpp @@ -1134,13 +1134,14 @@ QString InternalLibraryDetailsController::snippet() const const QString proRelavitePath = rootDir.relativeFilePath(proFile().toString()); // project for which we insert the snippet - const Project *project = SessionManager::projectForFile(proFile()); // the build directory of the active build configuration QDir rootBuildDir = rootDir; // If the project is unconfigured use the project dir - if (ProjectExplorer::Target *t = project->activeTarget()) - if (ProjectExplorer::BuildConfiguration *bc = t->activeBuildConfiguration()) - rootBuildDir.setPath(bc->buildDirectory().toString()); + if (const Project *project = SessionManager::projectForFile(proFile())) { + if (ProjectExplorer::Target *t = project->activeTarget()) + if (ProjectExplorer::BuildConfiguration *bc = t->activeBuildConfiguration()) + rootBuildDir.setPath(bc->buildDirectory().toString()); + } // the project for which we insert the snippet inside build tree QFileInfo pfi(rootBuildDir.filePath(proRelavitePath));