From 05045a16c36f65aa51bf3cc16d12f6b71d01a572 Mon Sep 17 00:00:00 2001
From: scott snyder <snyder@bnl.gov>
Date: Sat, 16 Mar 2019 23:06:59 +0100
Subject: [PATCH] GeneratorObjects: Fix a couple more HepMcParticleLink issues.

Fix potential infinite loop in looking up event container.

Treat barcode of 0x7fffffff as null.
---
 Generators/GeneratorObjects/src/HepMcParticleLink.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Generators/GeneratorObjects/src/HepMcParticleLink.cxx b/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
index bbbdc2afb3f8..42d20ddc2f2b 100644
--- a/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
+++ b/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
@@ -233,7 +233,7 @@ HepMcParticleLink::index_type HepMcParticleLink::eventIndex() const
   m_extBarcode.eventIndex (index, position);
   if (index == ExtendedBarCode::UNDEFINED) {
     // Don't trip the assertion for a null link.
-    if (barcode() == 0) return 0;
+    if (barcode() == 0 || barcode() == 0x7fffffff) return 0;
     cptr();
     m_extBarcode.eventIndex (index, position);
     assert (index != ExtendedBarCode::UNDEFINED);
@@ -326,8 +326,8 @@ SG::DataProxy* HepMcParticleLink::find_proxy (const IProxyDict* sg) const
   EBC_EVCOLL evColl = getEventCollection();
   assert (evColl < EBC_NCOLLKINDS);
   unsigned int hint_orig = s_hints[evColl];
+  if (hint_orig >= NKEYS) hint_orig = 0;
   unsigned int hint = hint_orig;
-  if (hint >= NKEYS) hint = 0;
   do {
     SG::DataProxy* proxy = sg->proxy (clid, s_keys[evColl][hint]);
     if (proxy) {
-- 
GitLab