From 67183d88ebe38e742f3a1131258e666fa2a87742 Mon Sep 17 00:00:00 2001 From: William Katz Date: Wed, 21 Jul 2021 23:00:24 -0700 Subject: [PATCH] :bug: when logs were empty .back() would seg fault --- src/bank.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bank.cpp b/src/bank.cpp index ac609eb..a74eeb2 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -198,7 +198,7 @@ BankResponse Bank::PruneUsers(time_t threshold_time, uint32_t threshold_bal) noe if (users.erase_if(u.first, [threshold_time, threshold_bal, &deleted_count](User &u) -> bool { #if MAX_LOG_SIZE > 0 - return (u.log.data.back().time < threshold_time && u.balance < threshold_bal); + return ((u.log.data.size() ? (u.log.data.back().time < threshold_time) : true) && u.balance < threshold_bal); #else return (u.balance < threshold_bal); #endif