Merge pull request #2537

269a2a01 blockchain: fix off by one getting blocks (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2017-10-06 22:56:17 +04:00
commit 4a20a5b5ea
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -1444,7 +1444,7 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<std::
{
LOG_PRINT_L3("Blockchain::" << __func__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
if(start_offset > m_db->height())
if(start_offset >= m_db->height())
return false;
if (!get_blocks(start_offset, count, blocks))
@ -1466,7 +1466,7 @@ bool Blockchain::get_blocks(uint64_t start_offset, size_t count, std::list<std::
{
LOG_PRINT_L3("Blockchain::" << __func__);
CRITICAL_REGION_LOCAL(m_blockchain_lock);
if(start_offset > m_db->height())
if(start_offset >= m_db->height())
return false;
for(size_t i = start_offset; i < start_offset + count && i < m_db->height();i++)