handle invalid arguments to set_piece_deadline()

This commit is contained in:
arvidn 2017-06-18 14:52:44 -04:00 committed by Arvid Norberg
parent f04d729d43
commit 046bb76361
3 changed files with 10 additions and 3 deletions

View File

@ -1,3 +1,4 @@
* handle invalid arguments to set_piece_deadline()
* move_storage did not work for torrents without metadata
* improve shutdown time by only announcing to trackers whose IP we know
* fix python3 portability issue in python binding

View File

@ -375,14 +375,14 @@ namespace libtorrent
// deadline (and flags) of a piece can be changed by calling this
// function again.
//
// The ``flags`` parameter can be used to ask libtorrent to send an alert
// The ``flags`` parameter can be used to ask libtorrent to post an alert
// once the piece has been downloaded, by passing alert_when_available.
// When set, the read_piece_alert alert will be delivered, with the piece
// data, when it's downloaded.
//
// If the piece is already downloaded when this call is made, nothing
// happens, unless the alert_when_available flag is set, in which case it
// will do the same thing as calling read_piece() for ``index``.
// will have the same effect as calling read_piece() for ``index``.
//
// ``deadline`` is the number of milliseconds until this piece should be
// completed.

View File

@ -5235,7 +5235,13 @@ namespace libtorrent
{
INVARIANT_CHECK;
if (m_abort)
TORRENT_ASSERT_PRECOND(piece >= 0);
TORRENT_ASSERT_PRECOND(valid_metadata());
TORRENT_ASSERT_PRECOND(valid_metadata() && piece < m_torrent_file->num_pieces());
if (m_abort || !valid_metadata()
|| piece < 0
|| piece >= m_torrent_file->num_pieces())
{
// failed
if (flags & torrent_handle::alert_when_available)