From 23e283f1355179168c2bcc2783d31ec3d6d67323 Mon Sep 17 00:00:00 2001 From: Anders Hafreager Date: Wed, 27 Sep 2017 16:20:07 +0200 Subject: [PATCH] Fixed proper deletion of fixes if fix is NULL --- src/modify.cpp | 10 ++++++++-- src/modify.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modify.cpp b/src/modify.cpp index 4516788aa9..b95d8868bf 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -110,7 +110,7 @@ Modify::~Modify() // delete all fixes // do it via delete_fix() so callbacks in Atom are also updated correctly - while (nfix) delete_fix(fix[0]->id); + while (nfix) delete_fix(0); memory->sfree(fix); memory->destroy(fmask); @@ -944,7 +944,13 @@ void Modify::delete_fix(const char *id) { int ifix = find_fix(id); if (ifix < 0) error->all(FLERR,"Could not find fix ID to delete"); - delete fix[ifix]; + delete_fix(ifix); +} + +void Modify::delete_fix(int ifix) +{ + if(fix[ifix]) + delete fix[ifix]; atom->update_callback(ifix); // move other Fixes and fmask down in list one slot diff --git a/src/modify.h b/src/modify.h index d825d5c4ef..4ec61f6d57 100644 --- a/src/modify.h +++ b/src/modify.h @@ -95,6 +95,7 @@ class Modify : protected Pointers { void add_fix(int, char **, int trysuffix=1); void modify_fix(int, char **); void delete_fix(const char *); + void delete_fix(int); int find_fix(const char *); int find_fix_by_style(const char *); int check_package(const char *);