From 66ed16760f93a928196d49e7d60697b93cb9e412 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 31 Oct 2020 11:48:29 -0400 Subject: [PATCH] do not allow access to rigid body properties before they are fully set up --- src/RIGID/fix_rigid.cpp | 4 ++++ src/RIGID/fix_rigid_small.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 68c44b3e26..9ce28438d3 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -2710,11 +2710,15 @@ double FixRigid::compute_scalar() void *FixRigid::extract(const char *str, int &dim) { + dim = 0; + if (strcmp(str,"body") == 0) { + if (!setupflag) return nullptr; dim = 1; return body; } if (strcmp(str,"masstotal") == 0) { + if (!setupflag) return nullptr; dim = 1; return masstotal; } diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index e867e5bb68..1b022f35c4 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -3424,7 +3424,10 @@ int FixRigidSmall::modify_param(int narg, char **arg) void *FixRigidSmall::extract(const char *str, int &dim) { + dim = 0; + if (strcmp(str,"body") == 0) { + if (!setupflag) return nullptr; dim = 1; return atom2body; } @@ -3438,6 +3441,7 @@ void *FixRigidSmall::extract(const char *str, int &dim) // used by granular pair styles, indexed by atom2body if (strcmp(str,"masstotal") == 0) { + if (!setupflag) return nullptr; dim = 1; if (nmax_mass < nmax_body) {