fixed buffer overrun when calling get_download_queue
This commit is contained in:
parent
7f0bfa37b9
commit
3144767632
|
@ -291,7 +291,7 @@ namespace libtorrent
|
||||||
|
|
||||||
struct TORRENT_EXPORT partial_piece_info
|
struct TORRENT_EXPORT partial_piece_info
|
||||||
{
|
{
|
||||||
enum { max_blocks_per_piece = 256 };
|
enum { max_blocks_per_piece = 512 };
|
||||||
int piece_index;
|
int piece_index;
|
||||||
int blocks_in_piece;
|
int blocks_in_piece;
|
||||||
// the number of blocks in the finished state
|
// the number of blocks in the finished state
|
||||||
|
|
|
@ -2839,7 +2839,8 @@ namespace libtorrent
|
||||||
pi.writing = (int)i->writing;
|
pi.writing = (int)i->writing;
|
||||||
pi.requested = (int)i->requested;
|
pi.requested = (int)i->requested;
|
||||||
int piece_size = int(torrent_file().piece_size(i->index));
|
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];
|
block_info& bi = pi.blocks[j];
|
||||||
bi.state = i->info[j].state;
|
bi.state = i->info[j].state;
|
||||||
|
|
Loading…
Reference in New Issue