From 0eac6f3c12225fe5fee89f123f7ce95d2200b6a0 Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Sun, 29 Jan 2017 04:06:57 +0100
Subject: [PATCH] Bugfix for insertMove with empty destination container.
 (AthContainers-00-03-26)

	* Tagging AthContainers-00-03-26.
	* Root/AuxStoreInternal.cxx (insertMove): Fix bug with empty
	destination container.  Leave early if source container is empty.
---
 Control/AthContainers/AthContainers/DataVector.h   | 2 +-
 Control/AthContainers/AthContainers/DataVector.icc | 2 +-
 Control/AthContainers/AthContainers/exceptions.h   | 2 +-
 Control/AthContainers/Root/AuxStoreInternal.cxx    | 3 +++
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Control/AthContainers/AthContainers/DataVector.h b/Control/AthContainers/AthContainers/DataVector.h
index 1709613f4f6..983ce753087 100644
--- a/Control/AthContainers/AthContainers/DataVector.h
+++ b/Control/AthContainers/AthContainers/DataVector.h
@@ -4,7 +4,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-// $Id: DataVector.h 794114 2017-01-26 22:01:53Z ssnyder $
+// $Id: DataVector.h 794113 2017-01-26 22:01:47Z ssnyder $
 
 /**
  * @file  AthContainers/DataVector.h
diff --git a/Control/AthContainers/AthContainers/DataVector.icc b/Control/AthContainers/AthContainers/DataVector.icc
index f6becbb78fe..478baaee6d0 100644
--- a/Control/AthContainers/AthContainers/DataVector.icc
+++ b/Control/AthContainers/AthContainers/DataVector.icc
@@ -4,7 +4,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-// $Id: DataVector.icc 794114 2017-01-26 22:01:53Z ssnyder $
+// $Id: DataVector.icc 794113 2017-01-26 22:01:47Z ssnyder $
 /**
  * @file  AthContainers/DataVector.icc
  * @author scott snyder, Paolo Calafiura, etc
diff --git a/Control/AthContainers/AthContainers/exceptions.h b/Control/AthContainers/AthContainers/exceptions.h
index 6a512d4e811..e95a6f409ad 100644
--- a/Control/AthContainers/AthContainers/exceptions.h
+++ b/Control/AthContainers/AthContainers/exceptions.h
@@ -4,7 +4,7 @@
   Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
 */
 
-// $Id: exceptions.h 794114 2017-01-26 22:01:53Z ssnyder $
+// $Id: exceptions.h 794113 2017-01-26 22:01:47Z ssnyder $
 /**
  * @file AthContainers/exceptions.h
  * @author scott snyder <snyder@bnl.gov>
diff --git a/Control/AthContainers/Root/AuxStoreInternal.cxx b/Control/AthContainers/Root/AuxStoreInternal.cxx
index 6507ad07198..ff38d13b306 100644
--- a/Control/AthContainers/Root/AuxStoreInternal.cxx
+++ b/Control/AthContainers/Root/AuxStoreInternal.cxx
@@ -317,6 +317,8 @@ bool AuxStoreInternal::insertMove (size_t pos,
     throw ExcStoreLocked ("insertMove");
   bool nomove = true;
   size_t other_size = other.size();
+  if (other_size == 0)
+    return true;
   for (SG::auxid_t id : m_auxids) {
     SG::IAuxTypeVector* v_dst = nullptr;
     if (id < m_vecs.size())
@@ -347,6 +349,7 @@ bool AuxStoreInternal::insertMove (size_t pos,
         void* src_ptr = other.getData (id, other_size, other_size);
         if (src_ptr) {
           size_t sz = size_noLock();
+          if (sz < other_size) sz = other_size;
           (void)getDataInternal_noLock (id, sz, sz, false);
           m_vecs[id]->resize (sz - other_size);
           m_vecs[id]->insertMove (pos, src_ptr, reinterpret_cast<char*>(src_ptr) + other_size*r.getEltSize(id));
-- 
GitLab