From f223708b0bf33972221e514f77dc3d8421851caa Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 23 Feb 2010 23:47:40 +0000 Subject: [PATCH] fixed assert when using odd piece size --- src/peer_connection.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index cbf7848e5..25370bdb1 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -4940,11 +4940,8 @@ namespace libtorrent bool in_download_queue = false; 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; + , (ti.piece_size(ti.num_pieces()-1) + block_size - 1) / block_size); + int last_block_size = t->torrent_file().piece_size(ti.num_pieces()-1) - last_block.block_index * block_size; for (std::vector::const_iterator i = m_download_queue.begin() , end(m_download_queue.end()); i != end; ++i) {