Skip to content

Commit

Permalink
Fix memory leak in JFactoryPodioT::Set
Browse files Browse the repository at this point in the history
This resolves issue #235.
  • Loading branch information
nathanwbrei committed Nov 21, 2023
1 parent a229aa7 commit 160bcdb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libraries/JANA/Podio/JFactoryPodioT.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ void JFactoryPodioT<T>::Set(const std::vector<T*>& aData) {
if (mIsSubsetCollection) collection.setSubsetCollection(true);
for (T* item : aData) {
collection.push_back(*item);
delete item;
}
SetCollection(std::move(collection));
}
Expand All @@ -203,6 +204,7 @@ void JFactoryPodioT<T>::Set(std::vector<T*>&& aData) {
if (mIsSubsetCollection) collection.setSubsetCollection(true);
for (T* item : aData) {
collection.push_back(*item);
delete item;
}
SetCollection(std::move(collection));
}
Expand All @@ -212,6 +214,7 @@ void JFactoryPodioT<T>::Insert(T* aDatum) {
CollectionT collection;
if (mIsSubsetCollection) collection->setSubsetCollection(true);
collection->push_back(*aDatum);
delete aDatum;
SetCollection(std::move(collection));
}

Expand Down

0 comments on commit 160bcdb

Please sign in to comment.