From 7ca60d62fc573a7ed7b564d8f19b3b8eb6b34919 Mon Sep 17 00:00:00 2001
From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk>
Date: Mon, 12 Oct 2015 09:49:10 +0100
Subject: [PATCH] API issues - prevent deref past the iterator end, 1075705, re
 #13918

---
 Framework/Geometry/src/Math/Acomp.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Framework/Geometry/src/Math/Acomp.cpp b/Framework/Geometry/src/Math/Acomp.cpp
index b84413e8f77..75c5fb5fe2b 100644
--- a/Framework/Geometry/src/Math/Acomp.cpp
+++ b/Framework/Geometry/src/Math/Acomp.cpp
@@ -366,7 +366,8 @@ Assumes that the component is sorted and inserts appropiately.
     for (acp = AX.Comp.begin(); acp != AX.Comp.end(); ++acp) {
       std::vector<Acomp>::iterator cpt;
       cpt = std::lower_bound(Comp.begin(), Comp.end(), *acp);
-      if (cpt == Comp.end() || *cpt != *aup) // Only insert if new
+      if (cpt == Comp.end() ||
+          (AX.Units.end() != aup && *cpt != *aup)) // Only insert if new
         Comp.insert(cpt, *acp);
     }
     return;
-- 
GitLab