diff --git a/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx b/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx
index a301a095dc400bc646e4e2ca70b67d92b193b797..e920a7fce4eeef32cd1d064c4cd6ed0d82d9f0aa 100644
--- a/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx
+++ b/Generators/GeneratorObjectsTPCnv/src/initMcEventCollection.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
 */
 #include "GeneratorObjectsTPCnv/initMcEventCollection.h"
 
@@ -150,9 +150,12 @@ namespace Athena_test {
     }
 #else
     if (!ge.vertices_empty()) {
-      for (auto itvtx = ge.vertices_begin(); itvtx != ge.vertices_end();
-           ++itvtx) {
-        ge.remove_vertex(*itvtx);
+      HepMC::GenEvent::vertex_iterator itvtx = ge.vertices_begin();
+      while (itvtx != ge.vertices_end()) {
+        HepMC::GenVertexPtr pvtx = *itvtx;
+        ++itvtx;
+        ge.remove_vertex(pvtx);
+        delete pvtx;
       }
     }
 #endif