From 43a28e7a491788ba72d1c75cb54f0b51c1c86e85 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 31 May 2007 02:22:04 +0000 Subject: [PATCH] fixed bug in write resume data --- src/torrent_handle.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index ffe7aaa29..4dc821d7d 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -564,9 +564,11 @@ namespace libtorrent for (int j = 0; j < num_bitmask_bytes; ++j) { unsigned char v = 0; - for (int k = 0; k < 8; ++k) + int bits = std::min(num_blocks_per_piece - j*8, 8); + for (int k = 0; k < bits; ++k) v |= i->info[j*8+k].finished?(1 << k):0; bitmask.insert(bitmask.end(), v); + assert(bits == 8 || j == num_bitmask_bytes - 1); } piece_struct["bitmask"] = bitmask;