Skip to content

Commit

Permalink
fix out of range access
Browse files Browse the repository at this point in the history
  • Loading branch information
jagannatharjun committed Dec 29, 2023
1 parent ae7b73b commit 82859b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2893,8 +2893,6 @@ void TorrentImpl::setPieceDeadline(const int index, const int deadline, const bo

void TorrentImpl::resetPieceDeadline(const int index)
{
Q_ASSERT(m_pieceDeadlines.contains(index));

const auto iter = m_pieceDeadlines.find(index);
if (iter == m_pieceDeadlines.end())
return;
Expand Down
3 changes: 2 additions & 1 deletion src/base/streaming/streamingmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace
// lastBytePos is optional, if not provided we should assume lastBytePos is at the end of the file
lastBytePos = fileSize - 1;

if (firstBytePos > lastBytePos)
if (firstBytePos > lastBytePos || lastBytePos >= fileSize)
return std::nullopt;

return Range {firstBytePos, lastBytePos};
Expand Down Expand Up @@ -234,6 +234,7 @@ void StreamingManager::doGET(StreamRequest *request, BitTorrent::Torrent *torren
}
}, range.size());


auto fileReader = new TorrentFileReader(torrent, fileIndex, range.firstBytePos, range.lastBytePos, streamResponse, request);

connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentAboutToBeRemoved, request, [fileReader, torrent](BitTorrent::Torrent *removedTorrent)
Expand Down

0 comments on commit 82859b2

Please sign in to comment.