Fix some more off-by-one errors on last piece

See: TRAC-4037 and e2584b04ff
This commit is contained in:
Mike Gelfand 2017-05-09 14:20:26 +03:00
parent 10556943e5
commit 6d5e48f9e2
2 changed files with 3 additions and 3 deletions

View File

@ -483,7 +483,7 @@ static void saveProgress(tr_variant* dict, tr_torrent* tor)
tr_file const* f = &inf->files[fi];
/* get the oldest and newest nonzero timestamps for pieces in this file */
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece]; p != pend; ++p)
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece] + 1; p != pend; ++p)
{
if (p->timeChecked == 0)
{
@ -627,7 +627,7 @@ static uint64_t loadProgress(tr_variant* dict, tr_torrent* tor)
{
tr_file const* f = &inf->files[fi];
tr_piece* p = &inf->pieces[f->firstPiece];
tr_piece const* pend = &inf->pieces[f->lastPiece];
tr_piece const* pend = &inf->pieces[f->lastPiece] + 1;
time_t const mtime = tr_torrentGetFileMTime(tor, fi);
time_t const timeChecked = mtime == t ? mtime : 0;

View File

@ -3456,7 +3456,7 @@ static void tr_torrentFileCompleted(tr_torrent* tor, tr_file_index_t fileIndex)
/* now that the file is complete and closed, we can start watching its
* mtime timestamp for changes to know if we need to reverify pieces */
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece]; p != pend; ++p)
for (p = &inf->pieces[f->firstPiece], pend = &inf->pieces[f->lastPiece] + 1; p != pend; ++p)
{
p->timeChecked = now;
}