diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index b9cbd97a0..3e5fbb1a4 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4346,6 +4346,8 @@ namespace libtorrent int block_size = t->block_size(); piece_block last_block(ti.num_pieces()-1 , (ti.total_size() & (ti.piece_length()-1)) / block_size); + if ((ti.total_size() & (ti.piece_length()-1)) == 0) + last_block.block_index = (ti.piece_length()-1) / block_size; int last_block_size = t->torrent_file().total_size() & (block_size-1); if (last_block_size == 0) last_block_size = block_size; for (std::vector::const_iterator i = m_download_queue.begin()