From 6b415b2d2caab04d34575880d4b55b0095cf052d Mon Sep 17 00:00:00 2001 From: sowle Date: Fri, 13 Dec 2019 18:42:15 +0300 Subject: [PATCH] wallet2: clear_transfers_from_flag made exception-free (it's often being called from a catch-clause) --- src/wallet/wallet2.cpp | 10 ++++++++-- src/wallet/wallet2.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index f820bc89..28adade0 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3692,16 +3692,22 @@ void wallet2::mark_transfers_with_flag(const std::vector& selected_tra } } //---------------------------------------------------------------------------------------------------- -void wallet2::clear_transfers_from_flag(const std::vector& selected_transfers, uint32_t flag, const std::string& reason /* = empty_string */) +void wallet2::clear_transfers_from_flag(const std::vector& selected_transfers, uint32_t flag, const std::string& reason /* = empty_string */) noexcept { + TRY_ENTRY(); for (uint64_t i : selected_transfers) { - THROW_IF_TRUE_WALLET_EX(i >= m_transfers.size(), error::wallet_internal_error, "i >= m_transfers.size()"); + if (i >= m_transfers.size()) + { + WLT_LOG_ERROR("INTERNAL ERROR: i: " << i << " >= m_transfers.size() : " << m_transfers.size()); + continue; + } uint32_t flags_before = m_transfers[i].m_flags; m_transfers[i].m_flags &= ~flag; WLT_LOG_L1("clearing transfer #" << std::setfill('0') << std::right << std::setw(3) << i << " from flag " << flag << " : " << flags_before << " -> " << m_transfers[i].m_flags << (reason.empty() ? "" : ", reason: ") << reason); } + CATCH_ENTRY_NO_RETURN(); } //---------------------------------------------------------------------------------------------------- void wallet2::exception_handler() diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 2bff7279..a1cc5b65 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -853,7 +853,7 @@ private: const std::vector& selected_indicies); void mark_transfers_as_spent(const std::vector& selected_transfers, const std::string& reason = std::string()); void mark_transfers_with_flag(const std::vector& selected_transfers, uint32_t flag, const std::string& reason = std::string(), bool throw_if_flag_already_set = false); - void clear_transfers_from_flag(const std::vector& selected_transfers, uint32_t flag, const std::string& reason = std::string()); + void clear_transfers_from_flag(const std::vector& selected_transfers, uint32_t flag, const std::string& reason = std::string()) noexcept; void exception_handler(); void exception_handler() const; uint64_t get_minimum_allowed_fee_for_contract(const crypto::hash& ms_id);