Fix ChainstateManager::AddChainstate() assertion crash

Check mempool exists before accessing size when prev_chainstate doesn't have initialized mempool.
This commit is contained in:
stringintech
2025-12-17 18:32:16 +03:30
parent 5f3d6bdb66
commit 2bc3265649

View File

@@ -6248,7 +6248,7 @@ Chainstate& ChainstateManager::AddChainstate(std::unique_ptr<Chainstate> chainst
// Transfer possession of the mempool to the chainstate.
// Mempool is empty at this point because we're still in IBD.
assert(prev_chainstate.m_mempool->size() == 0);
assert(!prev_chainstate.m_mempool || prev_chainstate.m_mempool->size() == 0);
assert(!curr_chainstate.m_mempool);
std::swap(curr_chainstate.m_mempool, prev_chainstate.m_mempool);
return curr_chainstate;