From 3e3ed89f33428e6324bca28f90b3bc966f7c804a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 2 May 2023 17:30:23 -0400 Subject: [PATCH] avoid out-of-range access if an angle/dihedral/improper type is set to 0 --- src/compute_count_type.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compute_count_type.cpp b/src/compute_count_type.cpp index 84b31e8b85..3cb2e6bc3a 100644 --- a/src/compute_count_type.cpp +++ b/src/compute_count_type.cpp @@ -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]++; } }