From 31debfd2c951ef1fec4d7cecb6512855a625c1f0 Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Thu, 18 Jun 2015 15:23:56 +0000
Subject: [PATCH] Coverity 59023: Move creation of inter to after check to
 avoid memory leak

---
 DDG4/src/Geant4InputAction.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/DDG4/src/Geant4InputAction.cpp b/DDG4/src/Geant4InputAction.cpp
index 1605bbc23..1245fbb4a 100644
--- a/DDG4/src/Geant4InputAction.cpp
+++ b/DDG4/src/Geant4InputAction.cpp
@@ -136,12 +136,13 @@ void Geant4InputAction::operator()(G4Event* event)   {
   vector<Particle*>         primaries;
   Geant4Event&              evt = context()->event();
   Geant4PrimaryEvent*       prim = evt.extension<Geant4PrimaryEvent>();
-  Geant4PrimaryInteraction* inter = new Geant4PrimaryInteraction();
 
   int result = readParticles(event->GetEventID(),primaries);
   if ( result != Geant4EventReader::EVENT_READER_OK )   {    // handle I/O error, but how?
     return;
   }
+
+  Geant4PrimaryInteraction* inter = new Geant4PrimaryInteraction();
   prim->add(m_mask, inter);
   // check if there is at least one particle
   if ( primaries.empty() ) return;
-- 
GitLab