diff --git a/include/libtorrent/bandwidth_manager.hpp b/include/libtorrent/bandwidth_manager.hpp index 706fc1d90..7b3d0214b 100644 --- a/include/libtorrent/bandwidth_manager.hpp +++ b/include/libtorrent/bandwidth_manager.hpp @@ -222,10 +222,13 @@ struct bandwidth_manager TORRENT_ASSERT(current_quota == m_current_quota); typename queue_t::const_iterator j = m_queue.begin(); - ++j; - for (typename queue_t::const_iterator i = m_queue.begin() - , end(m_queue.end()); i != end && j != end; ++i, ++j) - TORRENT_ASSERT(i->priority >= j->priority); + if (j != m_queue.end()) + { + ++j; + for (typename queue_t::const_iterator i = m_queue.begin() + , end(m_queue.end()); i != end && j != end; ++i, ++j) + TORRENT_ASSERT(i->priority >= j->priority); + } } #endif diff --git a/src/torrent.cpp b/src/torrent.cpp index 61aaa4785..48af6cf7e 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -2681,6 +2681,7 @@ namespace libtorrent for (int c = 0; c < 2; ++c) { queue_t::const_iterator j = m_bandwidth_queue[c].begin(); + if (j == m_bandwidth_queue[c].end()) continue; ++j; for (queue_t::const_iterator i = m_bandwidth_queue[c].begin() , end(m_bandwidth_queue[c].end()); i != end && j != end; ++i, ++j)