From 160bcdb0afcb1b335351c5f36b417c3b6acbdd28 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Tue, 21 Nov 2023 14:22:13 -0500 Subject: [PATCH] Fix memory leak in JFactoryPodioT::Set This resolves issue #235. --- src/libraries/JANA/Podio/JFactoryPodioT.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/JANA/Podio/JFactoryPodioT.h b/src/libraries/JANA/Podio/JFactoryPodioT.h index 279c0b709..c762e844f 100644 --- a/src/libraries/JANA/Podio/JFactoryPodioT.h +++ b/src/libraries/JANA/Podio/JFactoryPodioT.h @@ -193,6 +193,7 @@ void JFactoryPodioT::Set(const std::vector& aData) { if (mIsSubsetCollection) collection.setSubsetCollection(true); for (T* item : aData) { collection.push_back(*item); + delete item; } SetCollection(std::move(collection)); } @@ -203,6 +204,7 @@ void JFactoryPodioT::Set(std::vector&& aData) { if (mIsSubsetCollection) collection.setSubsetCollection(true); for (T* item : aData) { collection.push_back(*item); + delete item; } SetCollection(std::move(collection)); } @@ -212,6 +214,7 @@ void JFactoryPodioT::Insert(T* aDatum) { CollectionT collection; if (mIsSubsetCollection) collection->setSubsetCollection(true); collection->push_back(*aDatum); + delete aDatum; SetCollection(std::move(collection)); }