mirror of
https://github.com/monero-project/monero.git
synced 2025-07-31 20:18:43 -04:00
add empty container sanity checks when using front() and back()
This commit is contained in:
parent
56fa6ce15f
commit
45a1c4c088
9 changed files with 32 additions and 6 deletions
|
@ -62,6 +62,7 @@ void block_queue::add_blocks(uint64_t height, std::list<cryptonote::block_comple
|
|||
|
||||
void block_queue::add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, boost::posix_time::ptime time)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(nblocks > 0, "Empty span");
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
blocks.insert(span(height, nblocks, connection_id, time));
|
||||
}
|
||||
|
|
|
@ -1003,6 +1003,11 @@ skip:
|
|||
MDEBUG(context << " next span in the queue has blocks " << start_height << "-" << (start_height + blocks.size() - 1)
|
||||
<< ", we need " << previous_height);
|
||||
|
||||
if (blocks.empty())
|
||||
{
|
||||
MERROR("Next span has no blocks");
|
||||
break;
|
||||
}
|
||||
|
||||
block new_block;
|
||||
if (!parse_and_validate_block_from_blob(blocks.front().block, new_block))
|
||||
|
@ -1498,6 +1503,7 @@ skip:
|
|||
|
||||
NOTIFY_REQUEST_CHAIN::request r = boost::value_initialized<NOTIFY_REQUEST_CHAIN::request>();
|
||||
m_core.get_short_chain_history(r.block_ids);
|
||||
CHECK_AND_ASSERT_MES(!r.block_ids.empty(), false, "Short chain history is empty");
|
||||
|
||||
if (!start_from_current_chain)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue