mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 12:59:56 -07:00
Fix assertion fail
When fileSize == 0, the second index could be smaller than the first index, thus trigger the assert check in IndexInterval constructor. Closes #10611.
This commit is contained in:
parent
32ed5f1c8e
commit
f6d72fa79f
1 changed files with 7 additions and 2 deletions
|
@ -340,8 +340,13 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const
|
||||||
const libt::file_storage &files = nativeInfo()->files();
|
const libt::file_storage &files = nativeInfo()->files();
|
||||||
const auto fileSize = files.file_size(fileIndex);
|
const auto fileSize = files.file_size(fileIndex);
|
||||||
const auto fileOffset = files.file_offset(fileIndex);
|
const auto fileOffset = files.file_offset(fileIndex);
|
||||||
return makeInterval(static_cast<int>(fileOffset / pieceLength()),
|
|
||||||
static_cast<int>((fileOffset + fileSize - 1) / pieceLength()));
|
const int beginIdx = (fileOffset / pieceLength());
|
||||||
|
const int endIdx = ((fileOffset + fileSize - 1) / pieceLength());
|
||||||
|
|
||||||
|
if (fileSize <= 0)
|
||||||
|
return {beginIdx, 0};
|
||||||
|
return makeInterval(beginIdx, endIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentInfo::renameFile(const int index, const QString &newPath)
|
void TorrentInfo::renameFile(const int index, const QString &newPath)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue