1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-22 04:24:23 +00:00

Prevent crash due to race condition when adding magnet link

PR #19792.
This commit is contained in:
Vladimir Golovnev 2023-10-28 10:41:53 +03:00 committed by GitHub
parent 35e4b35d12
commit 12674d2990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2403,6 +2403,11 @@ bool SessionImpl::cancelDownloadMetadata(const TorrentID &id)
return false; return false;
const lt::torrent_handle nativeHandle = downloadedMetadataIter.value(); const lt::torrent_handle nativeHandle = downloadedMetadataIter.value();
m_downloadedMetadata.erase(downloadedMetadataIter);
if (!nativeHandle.is_valid())
return true;
#ifdef QBT_USES_LIBTORRENT2 #ifdef QBT_USES_LIBTORRENT2
const InfoHash infoHash {nativeHandle.info_hashes()}; const InfoHash infoHash {nativeHandle.info_hashes()};
if (infoHash.isHybrid()) if (infoHash.isHybrid())
@ -2413,7 +2418,7 @@ bool SessionImpl::cancelDownloadMetadata(const TorrentID &id)
m_downloadedMetadata.remove((altID == downloadedMetadataIter.key()) ? id : altID); m_downloadedMetadata.remove((altID == downloadedMetadataIter.key()) ? id : altID);
} }
#endif #endif
m_downloadedMetadata.erase(downloadedMetadataIter);
m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_files); m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_files);
return true; return true;
} }