From f47cc0cf4d14911f6ceb1b99a48b9bb701ccf97f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 25 Jan 2009 04:22:11 +0000 Subject: [PATCH] (trunk libT) #1794: possible fix -- better handling of zero-size files --- libtransmission/completion.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libtransmission/completion.c b/libtransmission/completion.c index 60297dc6d..276cbf224 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -324,7 +324,7 @@ tr_cpFileIsComplete( const tr_completion * cp, tr_file_index_t fileIndex ) const tr_torrent * tor = cp->tor; const tr_file * file = &tor->info.files[fileIndex]; const tr_block_index_t firstBlock = file->offset / tor->blockSize; - const tr_block_index_t lastBlock = ( file->offset + file->length - 1 ) / tor->blockSize; + const tr_block_index_t lastBlock = file->length ? ( ( file->offset + file->length - 1 ) / tor->blockSize ) : firstBlock; assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece ); assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece );