diff --git a/examples/connection_tester.cpp b/examples/connection_tester.cpp index b35a422d3..a820bac4e 100644 --- a/examples/connection_tester.cpp +++ b/examples/connection_tester.cpp @@ -840,7 +840,8 @@ void generate_data(char const* path, torrent_info const& ti) for (int j = 0; j < ti.piece_size(i); j += 0x4000) { generate_block(piece, i, j, 0x4000); - file::iovec_t b = { piece, 0x4000}; + int const left_in_piece = ti.piece_size(i) - j; + file::iovec_t const b = { piece, size_t(std::min(left_in_piece, 0x4000))}; storage_error error; st->writev(&b, 1, i, j, 0, error); if (error)