Browse Source

Prevent crash due to race condition when adding magnet link

PR #19792.
adaptive-webui-19844
Vladimir Golovnev 1 year ago committed by GitHub
parent
commit
12674d2990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/base/bittorrent/sessionimpl.cpp

7
src/base/bittorrent/sessionimpl.cpp

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

Loading…
Cancel
Save