diff --git a/src/balance.h b/src/balance.h index 2e3f003fbd..df8ac307b4 100644 --- a/src/balance.h +++ b/src/balance.h @@ -45,6 +45,7 @@ class Balance : public Command { int *bisection(int sortflag = 0); void dumpout(bigint); + static constexpr int BSTR_SIZE = 3; private: int me, nprocs; @@ -56,7 +57,6 @@ class Balance : public Command { int nitermax; // params for shift LB double stopthresh; - static constexpr int BSTR_SIZE = 3; char bstr[BSTR_SIZE+1]; int shift_allocate; // 1 if SHIFT vectors have been allocated diff --git a/src/fix_balance.cpp b/src/fix_balance.cpp index 40fa7255f6..2c76f13bf0 100644 --- a/src/fix_balance.cpp +++ b/src/fix_balance.cpp @@ -64,14 +64,15 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) : int iarg = 5; if (lbstyle == SHIFT) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix balance command"); - if (strlen(arg[iarg+1]) > 3) + if (strlen(arg[iarg+1]) > Balance::BSTR_SIZE) error->all(FLERR,"Illegal fix balance command"); - strcpy(bstr,arg[iarg+1]); + strncpy(bstr,arg[iarg+1], Balance::BSTR_SIZE+1); nitermax = utils::inumeric(FLERR,arg[iarg+2],false,lmp); if (nitermax <= 0) error->all(FLERR,"Illegal fix balance command"); stopthresh = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (stopthresh < 1.0) error->all(FLERR,"Illegal fix balance command"); iarg += 4; + } else if (lbstyle == BISECTION) { iarg++; }