From 15bf443bfdf9df41c06048e0bd952b6c443c76ea Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 4 Oct 2016 07:31:07 -0700 Subject: [PATCH] fix connection_tester to support generating fake data for arbitrary torrents (#1181) --- examples/connection_tester.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)