From f609c5902ab802bb83c72207be5f465ffae87af5 Mon Sep 17 00:00:00 2001 From: scott snyder <scott.snyder@cern.ch> Date: Mon, 11 Jun 2018 17:19:41 +0200 Subject: [PATCH] BeamPipeGeoModel: Another attempt to fix coverity 113158. coverity: possible null pointer dereference. Former-commit-id: e9ee2aefe53a0b6daa400fcc97e5b2043bf67a2b --- .../BeamPipeGeoModel/CMakeLists.txt | 3 ++- .../src/BeamPipeDetectorFactory.cxx | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/AtlasGeometryCommon/BeamPipeGeoModel/CMakeLists.txt b/AtlasGeometryCommon/BeamPipeGeoModel/CMakeLists.txt index f96cfa34430..60964ae54c0 100644 --- a/AtlasGeometryCommon/BeamPipeGeoModel/CMakeLists.txt +++ b/AtlasGeometryCommon/BeamPipeGeoModel/CMakeLists.txt @@ -14,6 +14,7 @@ atlas_depends_on_subdirs( PUBLIC Control/CLIDSvc Control/SGTools Control/StoreGate + Control/AthenaKernel DetectorDescription/GeoModel/GeoModelInterfaces GaudiKernel ) @@ -27,7 +28,7 @@ atlas_add_library( BeamPipeGeoModelLib PUBLIC_HEADERS BeamPipeGeoModel INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} GeoModelKernel GeoModelUtilities StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES SGTools GaudiKernel ) + PRIVATE_LINK_LIBRARIES SGTools AthenaKernel GaudiKernel ) atlas_add_component( BeamPipeGeoModel src/components/*.cxx diff --git a/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx b/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx index 7451c402d08..680541da220 100755 --- a/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx +++ b/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx @@ -25,6 +25,9 @@ #include "RDBAccessSvc/IRDBRecordset.h" #include "RDBAccessSvc/IRDBAccessSvc.h" +#include "AthenaKernel/getMessageSvc.h" +#include "GaudiKernel/MsgStream.h" + #include <iomanip> #include <vector> @@ -240,9 +243,15 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region) GeoNameTag* ntSection = new GeoNameTag(name); if (addToFirstSection && secNum!=1) { - //std::cout << "Placing section " << secNum << " in Section1" << std::endl; - pvMotherSection->add(ntSection); - pvMotherSection->add(pvSection); + if (!pvMotherSection) { + MsgStream gLog(Athena::getMessageSvc(), "BeamPipeDetectorFactory"); + gLog << MSG::ERROR << "Logic error building beam pipe." << endmsg; + } + else { + //std::cout << "Placing section " << secNum << " in Section1" << std::endl; + pvMotherSection->add(ntSection); + pvMotherSection->add(pvSection); + } } else { //std::cout << "Placing section " << secNum << " in mother envelope" << std::endl; parent->add(ntSection); -- GitLab