From b761a58171f2a7b2249211840aeb203a37dc8b13 Mon Sep 17 00:00:00 2001 From: pablomartin4btc Date: Wed, 18 Oct 2023 20:17:42 -0300 Subject: [PATCH] assumeutxo, blockstorage: prevent core dump on invalid hash Github-Pull: #28698 Rebased-from: 4a5be10b928d4ed33d223972537c1cb79163e79c --- src/node/blockstorage.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 53f616de23..058e524745 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -387,7 +387,12 @@ bool BlockManager::LoadBlockIndex(const std::optional& snapshot_blockha } if (snapshot_blockhash) { - const AssumeutxoData au_data = *Assert(GetParams().AssumeutxoForBlockhash(*snapshot_blockhash)); + const std::optional maybe_au_data = GetParams().AssumeutxoForBlockhash(*snapshot_blockhash); + if (!maybe_au_data) { + m_opts.notifications.fatalError(strprintf("Assumeutxo data not found for the given blockhash '%s'.", snapshot_blockhash->ToString())); + return false; + } + const AssumeutxoData& au_data = *Assert(maybe_au_data); m_snapshot_height = au_data.height; CBlockIndex* base{LookupBlockIndex(*snapshot_blockhash)};