From c53cf1166fb489349e6b7c71d2df1aaaf1594a1f Mon Sep 17 00:00:00 2001
From: Shaun Roe <shaun.roe@cern.ch>
Date: Thu, 27 Sep 2018 09:50:19 +0200
Subject: [PATCH] Avoid possible null pointer dereference in
 PixelClusterContainerCnv_p2.cxx (coverity 118826)

Former-commit-id: a3a1d14238a4017a75b0cb78fdb92a1cb9c17f98
---
 .../InDetEventTPCnv/src/PixelClusterContainerCnv_p2.cxx      | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/InnerDetector/InDetEventCnv/InDetEventTPCnv/src/PixelClusterContainerCnv_p2.cxx b/InnerDetector/InDetEventCnv/InDetEventTPCnv/src/PixelClusterContainerCnv_p2.cxx
index bc16bbd366c..9cbadbfe5fd 100644
--- a/InnerDetector/InDetEventCnv/InDetEventTPCnv/src/PixelClusterContainerCnv_p2.cxx
+++ b/InnerDetector/InDetEventCnv/InDetEventTPCnv/src/PixelClusterContainerCnv_p2.cxx
@@ -161,12 +161,15 @@ void  PixelClusterContainerCnv_p2::persToTrans(const InDet::PixelClusterContaine
 
 //================================================================
 InDet::PixelClusterContainer* PixelClusterContainerCnv_p2::createTransient(const InDet::PixelClusterContainer_p2* persObj, MsgStream& log) {
-    //    if (log.level() <= MSG::DEBUG) log << MSG::DEBUG << "PixelClusterContainerCnv_p2::createTransient called " << endmsg;
     if(!m_isInitialized) {
      if (this->initialize(log) != StatusCode::SUCCESS) {
       log << MSG::FATAL << "Could not initialize PixelClusterContainerCnv_p2 " << endmsg;
      }
     }
+    if (not m_pixId) {
+      log << MSG::FATAL << "nullptr for m_pixId in PixelClusterContainerCnv_p2::createTransient" << endmsg;
+      return nullptr;
+    }
     std::auto_ptr<InDet::PixelClusterContainer> trans(new InDet::PixelClusterContainer(m_pixId->wafer_hash_max()));
     persToTrans(persObj, trans.get(), log);
     return(trans.release());
-- 
GitLab