[Rivet-svn] rivet: Fix memory error: begin() and end() must be called on the...

Rivet Mercurial rivet at projects.hepforge.org
Tue Sep 5 18:00:02 BST 2017


details:   https://rivet.hepforge.org/hg/rivet/rev/e362201bafb3
branches:  
changeset: 6001:e362201bafb3
user:      David Grellscheid <david.grellscheid at durham.ac.uk>
date:      Tue Sep 05 17:53:23 2017 +0100
description:
Fix memory error: begin() and end() must be called on the same object.

The function DressedLeptons::dressedLeptons() returns a newly constructed
vector each time. It is not possible to iterate from dressedLeptons().begin()
to dressedLeptons().end() without saving the vector first in a temp variable.

diffs (13 lines):

--- a/src/Projections/ZFinder.cc	Tue Sep 05 14:28:54 2017 +0100
+++ b/src/Projections/ZFinder.cc	Tue Sep 05 17:53:23 2017 +0100
@@ -76,8 +76,8 @@
     // Get leptons and find an acceptable invariant mass OSSF pair
     const DressedLeptons& leptons = applyProjection<DressedLeptons>(e, "DressedLeptons");
     InvMassFinalState imfs(std::make_pair(_pid, -_pid), _minmass, _maxmass, _masstarget);
-    Particles tmp;
-    tmp.insert(tmp.end(), leptons.dressedLeptons().begin(), leptons.dressedLeptons().end());
+    auto dressed = leptons.dressedLeptons();
+    Particles tmp(dressed.begin(), dressed.end());
     imfs.calc(tmp);
     if (imfs.particlePairs().size() < 1) return;
 


More information about the Rivet-svn mailing list