Skip to content

Commit

Permalink
Prevent incorrect size from being used for creating array
Browse files Browse the repository at this point in the history
  • Loading branch information
glassez committed Jul 12, 2024
1 parent 418edc7 commit 96607ce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,11 +1466,13 @@ QBitArray TorrentImpl::pieces() const

QBitArray TorrentImpl::downloadingPieces() const
{
QBitArray result(piecesCount());
if (!hasMetadata())
return {};

std::vector<lt::partial_piece_info> queue;
m_nativeHandle.get_download_queue(queue);

QBitArray result {piecesCount()};
for (const lt::partial_piece_info &info : queue)
result.setBit(LT::toUnderlyingType(info.piece_index));

Expand Down

0 comments on commit 96607ce

Please sign in to comment.