From d1fe6369e805837a60a07f5dbc9645cf90e9d0b4 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Thu, 11 Apr 2024 17:18:26 -0500 Subject: [PATCH] GH-3 Fix: num_messages.clear() called before decrement --- libraries/chain/include/eosio/chain/vote_processor.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/eosio/chain/vote_processor.hpp b/libraries/chain/include/eosio/chain/vote_processor.hpp index 7786b07406..8e529edaa6 100644 --- a/libraries/chain/include/eosio/chain/vote_processor.hpp +++ b/libraries/chain/include/eosio/chain/vote_processor.hpp @@ -103,7 +103,9 @@ class vote_processor_t { bool remove_all_for_block(auto& idx, auto& it, const block_id_type& id) { while (it != idx.end() && (*it)->id() == id) { - --num_messages[(*it)->connection_id]; + if (auto& num = num_messages[(*it)->connection_id]; num != 0) + --num; + it = idx.erase(it); } return it == idx.end();