From 52f7bac69c2953cc0b495dd543186cd09a9817b9 Mon Sep 17 00:00:00 2001 From: Tomas Dado Date: Fri, 11 Apr 2025 10:31:52 +0200 Subject: [PATCH] Fix memory leak in RooAbsCollection and remove spurious if --- roofit/roofitcore/src/RooAbsCollection.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roofit/roofitcore/src/RooAbsCollection.cxx b/roofit/roofitcore/src/RooAbsCollection.cxx index 4389607df97b8..27b193aa7037c 100644 --- a/roofit/roofitcore/src/RooAbsCollection.cxx +++ b/roofit/roofitcore/src/RooAbsCollection.cxx @@ -929,8 +929,7 @@ RooAbsArg * RooAbsCollection::find(const char *name) const if (_hashAssistedFind || _list.size() >= _sizeThresholdForMapSearch) { if (!_hashAssistedFind || !_hashAssistedFind->isValid()) { - if (_hashAssistedFind) - delete _hashAssistedFind; + delete _hashAssistedFind; _hashAssistedFind = new HashAssistedFind{_list.begin(), _list.end()}; } @@ -951,6 +950,7 @@ RooAbsArg * RooAbsCollection::find(const RooAbsArg& arg) const if (_hashAssistedFind || _list.size() >= _sizeThresholdForMapSearch) { if (!_hashAssistedFind || !_hashAssistedFind->isValid()) { + delete _hashAssistedFind; _hashAssistedFind = new HashAssistedFind{_list.begin(), _list.end()}; }