diff --git a/src/piece_picker.cpp b/src/piece_picker.cpp index 654bd1f89..a7fc8aecd 100644 --- a/src/piece_picker.cpp +++ b/src/piece_picker.cpp @@ -860,6 +860,8 @@ namespace libtorrent std::vector::iterator i = find_dl_piece(index); TORRENT_ASSERT(i != m_downloads.end()); + TORRENT_ASSERT(i->info >= &m_block_info[0] + && i->info < &m_block_info[0] + m_block_info.size()); #ifdef TORRENT_DEBUG int num_blocks = blocks_in_piece(i->index); for (int k = 0; k < num_blocks; ++k) @@ -2185,6 +2187,8 @@ namespace libtorrent std::vector::const_iterator i = find_dl_piece(block.piece_index); TORRENT_ASSERT(i != m_downloads.end()); + TORRENT_ASSERT(i->info >= &m_block_info[0] + && i->info < &m_block_info[0] + m_block_info.size()); TORRENT_ASSERT(i->info[block.block_index].piece_index == block.piece_index); return i->info[block.block_index].state == block_info::state_requested; } @@ -2202,6 +2206,8 @@ namespace libtorrent if (m_piece_map[block.piece_index].downloading == 0) return false; std::vector::const_iterator i = find_dl_piece(block.piece_index); TORRENT_ASSERT(i != m_downloads.end()); + TORRENT_ASSERT(i->info >= &m_block_info[0] + && i->info < &m_block_info[0] + m_block_info.size()); TORRENT_ASSERT(i->info[block.block_index].piece_index == block.piece_index); return i->info[block.block_index].state == block_info::state_finished || i->info[block.block_index].state == block_info::state_writing; @@ -2221,6 +2227,8 @@ namespace libtorrent if (p.downloading == 0) return false; std::vector::const_iterator i = find_dl_piece(block.piece_index); TORRENT_ASSERT(i != m_downloads.end()); + TORRENT_ASSERT(i->info >= &m_block_info[0] + && i->info < &m_block_info[0] + m_block_info.size()); TORRENT_ASSERT(i->info[block.block_index].piece_index == block.piece_index); return i->info[block.block_index].state == block_info::state_finished; } @@ -2533,6 +2541,8 @@ namespace libtorrent TORRENT_ASSERT(index >= 0 && index <= (int)m_piece_map.size()); std::vector::const_iterator i = find_dl_piece(index); TORRENT_ASSERT(i != m_downloads.end()); + TORRENT_ASSERT(i->info >= &m_block_info[0] + && i->info < &m_block_info[0] + m_block_info.size()); d.clear(); for (int j = 0, end(blocks_in_piece(index)); j != end; ++j) diff --git a/test/setup_transfer.cpp b/test/setup_transfer.cpp index 4674a128c..66a523481 100644 --- a/test/setup_transfer.cpp +++ b/test/setup_transfer.cpp @@ -928,7 +928,7 @@ pid_type web_server_pid = 0; int start_web_server(bool ssl, bool chunked_encoding) { unsigned int seed = total_microseconds(time_now_hires() - min_time()); - printf("random seed: %u\n", seed); + fprintf(stderr, "random seed: %u\n", seed); std::srand(seed); int port = 5000 + (rand() % 55000);