blockchain: fix sizing of timestamps and cumulative_difficulty vectors

This commit is contained in:
moneromooo-monero 2015-08-23 11:24:12 +01:00
parent 5e3d56d6e3
commit 4707ccf1c3
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 2 additions and 2 deletions

View File

@ -856,8 +856,8 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std:
// and timestamps from it alone
else
{
timestamps.resize(static_cast<size_t>(DIFFICULTY_BLOCKS_COUNT));
cumulative_difficulties.resize(static_cast<size_t>(DIFFICULTY_BLOCKS_COUNT));
timestamps.resize(std::min(alt_chain.size(), static_cast<size_t>(DIFFICULTY_BLOCKS_COUNT)));
cumulative_difficulties.resize(std::min(alt_chain.size(), static_cast<size_t>(DIFFICULTY_BLOCKS_COUNT)));
size_t count = 0;
size_t max_i = timestamps.size()-1;
// get difficulties and timestamps from most recent blocks in alt chain