avoid segfault on deleting callback when there is an error in the constructor or a derived class

This commit is contained in:
Axel Kohlmeyer
2023-06-17 14:39:32 -04:00
parent 37ca3f9af8
commit 9231ec6dbe
3 changed files with 4 additions and 3 deletions

View File

@ -143,7 +143,8 @@ FixQEq::FixQEq(LAMMPS *lmp, int narg, char **arg) :
FixQEq::~FixQEq()
{
// unregister callbacks to this fix from Atom class
atom->delete_callback(id,Atom::GROW);
if (modify->get_fix_by_id(id)) atom->delete_callback(id,Atom::GROW);
memory->destroy(s_hist);
memory->destroy(t_hist);

View File

@ -481,7 +481,7 @@ FixRigidSmall::~FixRigidSmall()
{
// unregister callbacks to this fix from Atom class
atom->delete_callback(id,Atom::GROW);
if (modify->get_fix_by_id(id)) atom->delete_callback(id,Atom::GROW);
// delete locally stored arrays

View File

@ -255,7 +255,7 @@ FixShake::~FixShake()
// unregister callbacks to this fix from Atom class
atom->delete_callback(id,Atom::GROW);
if (modify->get_fix_by_id(id)) atom->delete_callback(id,Atom::GROW);
// set bond_type and angle_type back to positive for SHAKE clusters
// must set for all SHAKE bonds and angles stored by each atom