avoid out-of-range access if an angle/dihedral/improper type is set to 0

This commit is contained in:
Axel Kohlmeyer
2023-05-02 17:30:23 -04:00
parent 36632e3356
commit 3e3ed89f33

View File

@ -282,7 +282,7 @@ int ComputeCountType::count_angles()
if ((mask[j1] & groupbit) && (mask[j2] & groupbit) && (mask[j3] & groupbit)) {
if (itype > 0)
count[itype - 1]++;
else
else if (itype < 0)
count[-itype - 1]++;
}
}
@ -334,7 +334,7 @@ int ComputeCountType::count_dihedrals()
(mask[j4] & groupbit)) {
if (itype > 0)
count[itype - 1]++;
else
else if (itype < 0)
count[-itype - 1]++;
}
}
@ -386,7 +386,7 @@ int ComputeCountType::count_impropers()
(mask[j4] & groupbit)) {
if (itype > 0)
count[itype - 1]++;
else
else if (itype < 0)
count[-itype - 1]++;
}
}