Fix crash when torrent is deleted on limit reached

This commit is contained in:
Vladimir Golovnev (Glassez) 2020-04-23 16:53:00 +03:00
parent f1d02c6aee
commit 22bda12d6c
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7

View File

@ -1693,7 +1693,10 @@ void Session::processShareLimits()
{
qDebug("Processing share limits...");
for (TorrentHandleImpl *const torrent : asConst(m_torrents)) {
// We shouldn't iterate over `m_torrents` in the loop below
// since `deleteTorrent()` modifies it indirectly
const QHash<InfoHash, TorrentHandleImpl *> torrents {m_torrents};
for (TorrentHandleImpl *const torrent : torrents) {
if (torrent->isSeed() && !torrent->isForced()) {
if (torrent->ratioLimit() != TorrentHandle::NO_RATIO_LIMIT) {
const qreal ratio = torrent->realRatio();