Skip to content

Commit 6e50d2b

Browse files
authored
Merge pull request #48624 from iarspider/iarspider-patches-20250724-1
Fix stack-use-after-scope in HLTGenResHistColl::fillHists
2 parents 890536d + 0ecc13f commit 6e50d2b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Validation/HLTrigger/src/HLTGenResHistColl.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "Validation/HLTrigger/interface/HLTGenResHistColl.h"
2+
#include <optional>
23

34
namespace {
45
// function to get the trigger objects of a specific collection
@@ -141,20 +142,20 @@ void HLTGenResHistColl::bookHists(DQMStore::IBooker& iBooker) {
141142
void HLTGenResHistColl::fillHists(const HLTGenValObject& obj, edm::Handle<trigger::TriggerEvent>& triggerEvent) {
142143
// get the trigger objects of the collection
143144
auto keyRange = getTrigObjIndicesOfCollection(*triggerEvent, collectionName_, hltProcessName_);
144-
const trigger::TriggerObject* bestMatch = nullptr;
145+
std::optional<trigger::TriggerObject> bestMatch;
145146
float bestDR2 = dR2limit_;
146147
for (trigger::size_type key = keyRange.first; key < keyRange.second; ++key) {
147148
if (passFilterSelection(key, *triggerEvent)) {
148149
const trigger::TriggerObject objTrig = triggerEvent->getObjects().at(key);
149150
if (isEventLevelVariable_) {
150151
bestDR2 = 0;
151-
bestMatch = &objTrig;
152+
bestMatch = objTrig;
152153
break;
153154
} else {
154155
float dR2 = reco::deltaR2(obj, objTrig);
155156
if (dR2 < bestDR2) {
156157
bestDR2 = dR2;
157-
bestMatch = &objTrig;
158+
bestMatch = objTrig;
158159
}
159160
}
160161
}

0 commit comments

Comments
 (0)