1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

#589 fix crash that occurred when the next-to-last file in a torrent ended on a piece boundary and the last file had a size of 0 bytes.

This commit is contained in:
Charles Kerr 2008-01-08 03:08:36 +00:00
parent 2f3d027d04
commit 549778dc7e
2 changed files with 5 additions and 1 deletions

View file

@ -266,7 +266,7 @@ checkFile( tr_torrent * tor,
tr_buildPath ( path, sizeof(path), tor->destination, file->name, NULL );
nofile = stat( path, &sb ) || !S_ISREG( sb.st_mode );
for( i=file->firstPiece; i<=file->lastPiece && (!*abortFlag); ++i )
for( i=file->firstPiece; i<=file->lastPiece && i<tor->info.pieceCount && (!*abortFlag); ++i )
{
if( nofile )
{

View file

@ -810,6 +810,10 @@ tr_torrentSetHasPiece( tr_torrent * tor, int pieceIndex, int has )
{
tr_torrentLock( tor );
assert( tor != NULL );
assert( pieceIndex >= 0 );
assert( pieceIndex < tor->info.pieceCount );
if( has )
tr_cpPieceAdd( tor->completion, pieceIndex );
else