From f00a113a07e3b3c09ca140c8919dda99ac38df03 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 11 Dec 2024 16:50:40 -0600 Subject: [PATCH] Fixed memory leak in RegionalMuonGMTUnpacker --- .../RegionalMuonGMTUnpacker.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/RegionalMuonGMTUnpacker.cc b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/RegionalMuonGMTUnpacker.cc index 6251276b417a2..46d956f27eed1 100644 --- a/EventFilter/L1TRawToDigi/plugins/implementations_stage2/RegionalMuonGMTUnpacker.cc +++ b/EventFilter/L1TRawToDigi/plugins/implementations_stage2/RegionalMuonGMTUnpacker.cc @@ -34,18 +34,14 @@ namespace l1t { unsigned int linkId = blockId / 2; int processor; RegionalMuonCandBxCollection* regionalMuonCollection; - RegionalMuonShowerBxCollection* regionalMuonShowerCollection; + RegionalMuonShowerBxCollection* regionalMuonShowerCollection = nullptr; tftype trackFinder; if (linkId > 47 && linkId < 60) { regionalMuonCollection = static_cast(coll)->getRegionalMuonCandsBMTF(); - regionalMuonShowerCollection = - new RegionalMuonShowerBxCollection(); // To avoid warning re uninitialised collection trackFinder = tftype::bmtf; processor = linkId - 48; } else if (linkId > 41 && linkId < 66) { regionalMuonCollection = static_cast(coll)->getRegionalMuonCandsOMTF(); - regionalMuonShowerCollection = - new RegionalMuonShowerBxCollection(); // To avoid warning re uninitialised collection if (linkId < 48) { trackFinder = tftype::omtf_pos; processor = linkId - 42; @@ -68,8 +64,9 @@ namespace l1t { return false; } regionalMuonCollection->setBXRange(firstBX, lastBX); - regionalMuonShowerCollection->setBXRange(firstBX, lastBX); - + if (regionalMuonShowerCollection) { + regionalMuonShowerCollection->setBXRange(firstBX, lastBX); + } LogDebug("L1T") << "nBX = " << nBX << " first BX = " << firstBX << " lastBX = " << lastBX; // Get the BX blocks and unpack them @@ -127,7 +124,8 @@ namespace l1t { // Fill RegionalMuonShower objects. For this we need to look at all six words together. RegionalMuonShower muShower; if (RegionalMuonRawDigiTranslator::fillRegionalMuonShower( - muShower, bxPayload, processor, trackFinder, useEmtfNominalTightShowers_, useEmtfLooseShowers_)) { + muShower, bxPayload, processor, trackFinder, useEmtfNominalTightShowers_, useEmtfLooseShowers_) and + regionalMuonShowerCollection) { regionalMuonShowerCollection->push_back(bx, muShower); } } else {