make certain that the mass and mass_setflag arrays are fully initialized (to zero)

This commit is contained in:
Axel Kohlmeyer
2024-08-31 06:20:44 -04:00
parent 6ebdb0b982
commit 70a62d5ebf

View File

@ -1911,7 +1911,11 @@ void Atom::allocate_type_arrays()
if (avec->mass_type == AtomVec::PER_TYPE) {
mass = new double[ntypes+1];
mass_setflag = new int[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) mass_setflag[itype] = 0;
// start loop from 0 to avoid uninitialized access when operating on the whole array
for (int itype = 0; itype <= ntypes; itype++) {
mass_setflag[itype] = 0;
mass[itype] = 0.0;
}
}
}