correctly check for 32bit integer overflow
This commit is contained in:
@ -58,8 +58,8 @@ ComputePODDAtom::ComputePODDAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
pod = nullptr;
|
pod = nullptr;
|
||||||
elements = nullptr;
|
elements = nullptr;
|
||||||
|
|
||||||
if (((((MAXBIGINT*3.0)*atom->natoms)*podptr->nClusters)*podptr->Mdesc) > (MAXSMALLINT*1.0))
|
if ((((3.0*atom->natoms)*podptr->nClusters)*podptr->Mdesc) > (MAXSMALLINT*1.0))
|
||||||
error->all(FLERR, "Per-atom data too large");
|
error->all(FLERR, "Too many atoms ({}_ for compute {}", atom->natoms, style);
|
||||||
size_peratom_cols = 3 * atom->natoms * podptr->Mdesc * podptr->nClusters;
|
size_peratom_cols = 3 * atom->natoms * podptr->Mdesc * podptr->nClusters;
|
||||||
peratom_flag = 1;
|
peratom_flag = 1;
|
||||||
}
|
}
|
||||||
@ -110,8 +110,8 @@ void ComputePODDAtom::compute_peratom()
|
|||||||
if (atom->natoms > nmax) {
|
if (atom->natoms > nmax) {
|
||||||
memory->destroy(pod);
|
memory->destroy(pod);
|
||||||
nmax = atom->natoms;
|
nmax = atom->natoms;
|
||||||
if (((((MAXBIGINT*3.0)*atom->natoms)*podptr->nClusters)*podptr->Mdesc) > (MAXSMALLINT*1.0))
|
if ((((3.0*atom->natoms)*podptr->nClusters)*podptr->Mdesc) > (MAXSMALLINT*1.0))
|
||||||
error->all(FLERR, "Per-atom data too large");
|
error->all(FLERR, "Too many atoms ({}) for compute {}", atom->natoms, style);
|
||||||
int numdesc = 3 * atom->natoms * podptr->Mdesc * podptr->nClusters;
|
int numdesc = 3 * atom->natoms * podptr->Mdesc * podptr->nClusters;
|
||||||
memory->create(pod, nmax, numdesc,"podd/atom:pod");
|
memory->create(pod, nmax, numdesc,"podd/atom:pod");
|
||||||
array_atom = pod;
|
array_atom = pod;
|
||||||
|
|||||||
Reference in New Issue
Block a user