makes sure a torrent doesn't have too many pieces than can be handled. Fixes #61

This commit is contained in:
Arvid Norberg 2008-06-19 11:28:34 +00:00
parent 18809681be
commit d2bde64e71
2 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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