forked from premiere/premiere-libtorrent
makes sure a torrent doesn't have too many pieces than can be handled. Fixes #61
This commit is contained in:
parent
18809681be
commit
d2bde64e71
|
@ -475,6 +475,10 @@ namespace libtorrent
|
|||
// if this is set to true, it means update_pieces()
|
||||
// has to be called before accessing m_pieces.
|
||||
mutable bool m_dirty;
|
||||
public:
|
||||
|
||||
enum { max_pieces = piece_pos::we_have_index - 1 };
|
||||
|
||||
};
|
||||
|
||||
inline int piece_picker::blocks_in_piece(int index) const
|
||||
|
|
|
@ -407,6 +407,13 @@ namespace libtorrent
|
|||
|
||||
m_block_size = (std::min)(m_block_size, m_torrent_file->piece_length());
|
||||
|
||||
if (m_torrent_file->num_pieces()
|
||||
> piece_picker::max_pieces)
|
||||
{
|
||||
m_error = "too many pieces in torrent";
|
||||
pause();
|
||||
}
|
||||
|
||||
// the shared_from_this() will create an intentional
|
||||
// cycle of ownership, se the hpp file for description.
|
||||
m_owning_storage = new piece_manager(shared_from_this(), m_torrent_file
|
||||
|
|
Loading…
Reference in New Issue