From b17cd2a4881e5f318e955f86fbacbe3041efe7f0 Mon Sep 17 00:00:00 2001
From: scott snyder <scott.snyder@cern.ch>
Date: Tue, 24 Jul 2018 16:10:34 +0200
Subject: [PATCH] BeamPipeGeoModel: Coverity 118793, 118794.

Fix coverity warning: potential memory leak on error path.


Former-commit-id: d56d09047b577f0cb167b4bd7c085c8db375212b
---
 .../BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx       | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx b/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx
index 680541da220..ff888b08c63 100755
--- a/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx
+++ b/AtlasGeometryCommon/BeamPipeGeoModel/src/BeamPipeDetectorFactory.cxx
@@ -218,6 +218,7 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region)
 
     GeoLogVol* lvSection = new GeoLogVol(name,shape,mat);
     GeoPhysVol* pvSection = new GeoPhysVol(lvSection);
+    pvSection->ref();
     
     // Determine if this is a geometry where the first section can act as the mother of the following
     // sections. The following sections are only added to this if their ave CLHEP::radius is within the CLHEP::radial
@@ -241,6 +242,7 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region)
     GeoTransform* tfSection = 0;
     if (znew != 0 && (secNum==1 || !addToFirstSection)) tfSection = new GeoTransform(HepGeom::TranslateZ3D(znew));
     GeoNameTag* ntSection = new GeoNameTag(name);
+    ntSection->ref();
 
     if (addToFirstSection && secNum!=1) {
       if (!pvMotherSection) {
@@ -274,7 +276,10 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region)
       parent->add(tfSectionRot);
       parent->add(pvSection);
     }
-  }  
+
+    pvSection->unref();
+    ntSection->unref();
+  }
 }
 
 const BeamPipeDetectorManager * BeamPipeDetectorFactory::getDetectorManager() const
-- 
GitLab