From 4707ccf1c3236a885ff362efad1021e1b8e8abb3 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 23 Aug 2015 11:24:12 +0100 Subject: [PATCH] blockchain: fix sizing of timestamps and cumulative_difficulty vectors --- src/cryptonote_core/blockchain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index cf50a6cc4..60b3938c9 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -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(DIFFICULTY_BLOCKS_COUNT)); - cumulative_difficulties.resize(static_cast(DIFFICULTY_BLOCKS_COUNT)); + timestamps.resize(std::min(alt_chain.size(), static_cast(DIFFICULTY_BLOCKS_COUNT))); + cumulative_difficulties.resize(std::min(alt_chain.size(), static_cast(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