forked from premiere/premiere-libtorrent
fix integer overflow assert
This commit is contained in:
parent
08523e3855
commit
ec5555940b
|
@ -57,8 +57,9 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(index >= 0 && index < num_pieces());
|
||||
if (index == num_pieces()-1)
|
||||
{
|
||||
int size = int(total_size()
|
||||
- size_type(num_pieces() - 1) * piece_length());
|
||||
size_type size_except_last = num_pieces() - 1;
|
||||
size_except_last *= piece_length();
|
||||
int size = int(total_size() - size_except_last);
|
||||
TORRENT_ASSERT(size > 0);
|
||||
TORRENT_ASSERT(size <= piece_length());
|
||||
return int(size);
|
||||
|
|
Loading…
Reference in New Issue