From d5e6bcd9d38a892f11cd7f15c01d668b15aed76e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sun, 31 Jan 2021 22:13:43 -0500 Subject: [PATCH] correctly check for index and dimensionality --- src/compute_chunk_atom.cpp | 4 ++-- src/compute_chunk_spread_atom.cpp | 4 ++-- src/compute_reduce_chunk.cpp | 4 ++-- src/compute_slice.cpp | 6 ++++-- src/fix_ave_atom.cpp | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index db16830312..96bb5003f9 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -150,11 +150,11 @@ ComputeChunkAtom::ComputeChunkAtom(LAMMPS *lmp, int narg, char **arg) : ArgInfo argi(arg[3]); which = argi.get_type(); - argindex = argi.get_dim(); + argindex = argi.get_index1(); cfvid = argi.copy_name(); if ((which == ArgInfo::UNKNOWN) || (which == ArgInfo::NONE) - || (argindex > 1)) + || (argi.get_dim() > 1)) error->all(FLERR,"Illegal compute chunk/atom command"); } diff --git a/src/compute_chunk_spread_atom.cpp b/src/compute_chunk_spread_atom.cpp index 965c0d5cc7..ae7d855dbf 100644 --- a/src/compute_chunk_spread_atom.cpp +++ b/src/compute_chunk_spread_atom.cpp @@ -69,11 +69,11 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) : ArgInfo argi(arg[iarg], ArgInfo::COMPUTE|ArgInfo::FIX); which[nvalues] = argi.get_type(); - argindex[nvalues] = argi.get_dim(); + argindex[nvalues] = argi.get_index1(); ids[nvalues] = argi.copy_name(); if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE) - || (argindex[nvalues] > 1)) + || (argi.get_dim() > 1)) error->all(FLERR,"Illegal compute chunk/spread/atom command"); nvalues++; diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index 83dbcbe11a..9be88a74d0 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -85,11 +85,11 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) : ArgInfo argi(arg[iarg]); which[nvalues] = argi.get_type(); - argindex[nvalues] = argi.get_dim(); + argindex[nvalues] = argi.get_index1(); ids[nvalues] = argi.copy_name(); if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE) - || (argindex[nvalues] > 1)) + || (argi.get_dim() > 1)) error->all(FLERR,"Illegal compute reduce/chunk command"); nvalues++; diff --git a/src/compute_slice.cpp b/src/compute_slice.cpp index 8713063fdf..d8b6ee395a 100644 --- a/src/compute_slice.cpp +++ b/src/compute_slice.cpp @@ -56,12 +56,14 @@ ComputeSlice::ComputeSlice(LAMMPS *lmp, int narg, char **arg) : ArgInfo argi(arg[iarg]); which[nvalues] = argi.get_type(); - argindex[nvalues] = argi.get_dim(); + argindex[nvalues] = argi.get_index1(); ids[nvalues] = argi.copy_name(); if ((which[nvalues] == ArgInfo::UNKNOWN) || (which[nvalues] == ArgInfo::NONE) - || (argindex[nvalues] > 1)) + || (argi.get_dim() > 1)) error->all(FLERR,"Illegal compute slice command"); + + nvalues++; } // setup and error check diff --git a/src/fix_ave_atom.cpp b/src/fix_ave_atom.cpp index d59d39a2e8..04163bfa84 100644 --- a/src/fix_ave_atom.cpp +++ b/src/fix_ave_atom.cpp @@ -99,11 +99,11 @@ FixAveAtom::FixAveAtom(LAMMPS *lmp, int narg, char **arg) : ArgInfo argi(arg[i]); which[i] = argi.get_type(); - argindex[i] = argi.get_dim(); + argindex[i] = argi.get_index1(); ids[i] = argi.copy_name(); if ((which[i] == ArgInfo::UNKNOWN) || (which[i] == ArgInfo::NONE) - || (argindex[i] > 1)) + || (argi.get_dim() > 1)) error->all(FLERR,"Illegal fix ave/atom command"); } }