fixed buffer overrun when calling get_download_queue

This commit is contained in:
Arvid Norberg 2008-10-05 07:23:46 +00:00
parent 7f0bfa37b9
commit 3144767632
2 changed files with 3 additions and 2 deletions

View File

@ -291,7 +291,7 @@ namespace libtorrent
struct TORRENT_EXPORT partial_piece_info
{
enum { max_blocks_per_piece = 256 };
enum { max_blocks_per_piece = 512 };
int piece_index;
int blocks_in_piece;
// the number of blocks in the finished state

View File

@ -2839,7 +2839,8 @@ namespace libtorrent
pi.writing = (int)i->writing;
pi.requested = (int)i->requested;
int piece_size = int(torrent_file().piece_size(i->index));
for (int j = 0; j < pi.blocks_in_piece; ++j)
int num_blocks = (std::min)(pi.blocks_in_piece, int(partial_piece_info::max_blocks_per_piece));
for (int j = 0; j < num_blocks; ++j)
{
block_info& bi = pi.blocks[j];
bi.state = i->info[j].state;