From 70a62d5ebfb8b9ba32eef1127c6d8124e8b93ac4 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 31 Aug 2024 06:20:44 -0400 Subject: [PATCH] make certain that the mass and mass_setflag arrays are fully initialized (to zero) --- src/atom.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/atom.cpp b/src/atom.cpp index 4a638652c7..f8a9bdd79b 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -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; + } } }