Skip to content
Snippets Groups Projects
Commit b17cd2a4 authored by Scott Snyder's avatar Scott Snyder Committed by scott snyder
Browse files

BeamPipeGeoModel: Coverity 118793, 118794.

Fix coverity warning: potential memory leak on error path.


Former-commit-id: d56d0904
parent a3119d51
No related branches found
No related tags found
No related merge requests found
...@@ -218,6 +218,7 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region) ...@@ -218,6 +218,7 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region)
GeoLogVol* lvSection = new GeoLogVol(name,shape,mat); GeoLogVol* lvSection = new GeoLogVol(name,shape,mat);
GeoPhysVol* pvSection = new GeoPhysVol(lvSection); 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 // 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 // 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) ...@@ -241,6 +242,7 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region)
GeoTransform* tfSection = 0; GeoTransform* tfSection = 0;
if (znew != 0 && (secNum==1 || !addToFirstSection)) tfSection = new GeoTransform(HepGeom::TranslateZ3D(znew)); if (znew != 0 && (secNum==1 || !addToFirstSection)) tfSection = new GeoTransform(HepGeom::TranslateZ3D(znew));
GeoNameTag* ntSection = new GeoNameTag(name); GeoNameTag* ntSection = new GeoNameTag(name);
ntSection->ref();
if (addToFirstSection && secNum!=1) { if (addToFirstSection && secNum!=1) {
if (!pvMotherSection) { if (!pvMotherSection) {
...@@ -274,7 +276,10 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region) ...@@ -274,7 +276,10 @@ void BeamPipeDetectorFactory::addSections(GeoPhysVol* parent, int region)
parent->add(tfSectionRot); parent->add(tfSectionRot);
parent->add(pvSection); parent->add(pvSection);
} }
}
pvSection->unref();
ntSection->unref();
}
} }
const BeamPipeDetectorManager * BeamPipeDetectorFactory::getDetectorManager() const const BeamPipeDetectorManager * BeamPipeDetectorFactory::getDetectorManager() const
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment