From 22bda12d6c5c564c7095ed0ec90caf84845f9c88 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Thu, 23 Apr 2020 16:53:00 +0300 Subject: [PATCH] Fix crash when torrent is deleted on limit reached --- src/base/bittorrent/session.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index 9995f649d..1a3aaa332 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -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 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();