Skip to content

Commit 4997754

Browse files
authored
997 Resolve size_t underflow while removing dublicates in dynamic NPIs by using int (#998)
If damping_expr.get_dampings().size() == 0, then damping_expr.get_dampings().size() - 1 became a very large positive number, not -1
1 parent 65f0b3f commit 4997754

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

cpp/memilio/epidemiology/dynamic_npis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void implement_dynamic_npis(DampingExprGroup& damping_expr_group, const std::vec
320320
for (auto& damping_expr : damping_expr_group) {
321321
//go from the back so indices aren't invalidated when dampings are removed
322322
//use indices to loop instead of reverse iterators because removing invalidates the current iterator
323-
for (auto i = size_t(0); i < damping_expr.get_dampings().size() - 1; ++i) {
323+
for (auto i = int(0); i < int(damping_expr.get_dampings().size()) - 1; ++i) {
324324
auto it = damping_expr.get_dampings().rbegin() + i;
325325

326326
//look for previous damping of the same type/level

0 commit comments

Comments
 (0)