fixed an incorrect assert that was hit when having empty files in a torrent

This commit is contained in:
Arvid Norberg 2005-03-12 10:12:36 +00:00
parent 89b1f1f5d5
commit 78a1ef3cd9
1 changed files with 3 additions and 2 deletions

View File

@ -492,6 +492,7 @@ namespace libtorrent
file_offset -= file_iter->size; file_offset -= file_iter->size;
++file_iter; ++file_iter;
assert(file_iter != m_pimpl->info.end_files());
} }
path p(m_pimpl->save_path / get_filename(m_pimpl->info, file_iter->path)); path p(m_pimpl->save_path / get_filename(m_pimpl->info, file_iter->path));
@ -524,12 +525,12 @@ namespace libtorrent
int write_bytes = left_to_write; int write_bytes = left_to_write;
if (file_offset + write_bytes > file_iter->size) if (file_offset + write_bytes > file_iter->size)
{ {
assert(file_iter->size > file_offset); assert(file_iter->size >= file_offset);
write_bytes = static_cast<int>(file_iter->size - file_offset); write_bytes = static_cast<int>(file_iter->size - file_offset);
} }
assert(buf_pos >= 0); assert(buf_pos >= 0);
assert(write_bytes > 0); assert(write_bytes >= 0);
size_type written = out->write(buf + buf_pos, write_bytes); size_type written = out->write(buf + buf_pos, write_bytes);
if (written != write_bytes) if (written != write_bytes)