diff --git a/src/USER-MISC/compute_pressure_cylinder.cpp b/src/USER-MISC/compute_pressure_cylinder.cpp index ebe28d848a2519c55bb39197e7d1138d89a769b7..04767eb4c386a13e575be4ecd2f022cd728b3793 100644 --- a/src/USER-MISC/compute_pressure_cylinder.cpp +++ b/src/USER-MISC/compute_pressure_cylinder.cpp @@ -61,17 +61,20 @@ ComputePressureCyl::ComputePressureCyl(LAMMPS *lmp, int narg, char **arg) : Rmax=force->numeric(FLERR,arg[5]); bin_width=force->numeric(FLERR,arg[6]); - if (bin_width<0.0 || bin_width<Rmax) + if ((bin_width <= 0.0) || (bin_width < Rmax)) error->all(FLERR,"Illegal compute pressure/cylinder command"); - if (zhi<zlo || (zhi-zlo)<bin_width) + if ((zhi < zlo) || ((zhi-zlo) < bin_width)) error->all(FLERR,"Illegal compute pressure/cylinder command"); - if (zhi>domain->boxhi[2] || zlo<domain->boxlo[2]) + if ((zhi > domain->boxhi[2]) || (zlo < domain->boxlo[2])) error->all(FLERR,"Illegal compute pressure/cylinder command"); nbins=(int)(Rmax/bin_width); nzbins=(int)((zhi-zlo)/bin_width); - - if (nbins<1 or nzbins<1) + + // NOTE: at 2^22 = 4.2M bins, we will be close to exhausting allocatable + // memory on a 32-bit environment. so we use this as an upper limit. + + if ((nbins < 1) || (nzbins < 1) || (nbins > 2>>22) || (nbins > 2>>22)) error->all(FLERR,"Illegal compute pressure/cylinder command"); array_flag=1;