From d291fcb5d95967d1a7dd31dcb379cb2afc6ba1da Mon Sep 17 00:00:00 2001
From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa>
Date: Fri, 1 Jul 2016 22:39:26 +0000
Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@15241
 f3b2605a-c512-4ea7-a41b-209d697bcdaa

---
 src/atom_vec_body.cpp | 7 ++++---
 src/my_pool_chunk.h   | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp
index 64e280fb69..30efb33e7b 100644
--- a/src/atom_vec_body.cpp
+++ b/src/atom_vec_body.cpp
@@ -195,9 +195,10 @@ void AtomVecBody::copy(int i, int j, int delflag)
   // if deleting atom J via delflag and J has bonus data, then delete it
 
   if (delflag && body[j] >= 0) {
-    icp->put(bonus[body[j]].iindex);
-    dcp->put(bonus[body[j]].dindex);
-    copy_bonus(nlocal_bonus-1,body[j]);
+    int k = body[j];
+    icp->put(bonus[k].iindex);
+    dcp->put(bonus[k].dindex);
+    copy_bonus(nlocal_bonus-1,k);
     nlocal_bonus--;
   }
 
diff --git a/src/my_pool_chunk.h b/src/my_pool_chunk.h
index f55da598c2..7785ca41d6 100644
--- a/src/my_pool_chunk.h
+++ b/src/my_pool_chunk.h
@@ -148,8 +148,10 @@ class MyPoolChunk {
   }
 
   // return indexed chunk to pool via free list
+  // index = -1 for no allocated chunk
 
   void put(int index) {
+    if (index < 0) return;
     int ipage = index/chunkperpage;
     int ibin = whichbin[ipage];
     nchunk--;
-- 
GitLab