1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-21 23:32:35 +00:00

fix: obtain session lock before getting tor ptr (#7286)

This commit is contained in:
Yat Ho 2024-12-13 05:17:07 +08:00 committed by GitHub
parent 8bca3f2e06
commit b2ce9eea83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1603,21 +1603,16 @@ void tr_torrentVerify(tr_torrent* tor)
tor->session->run_in_session_thread(
[session = tor->session, tor_id = tor->id()]()
{
TR_ASSERT(session->am_in_session_thread());
auto const lock = session->unique_lock();
auto* const tor = session->torrents().get(tor_id);
if (tor == nullptr)
if (tor == nullptr || tor->is_deleting_)
{
return;
}
TR_ASSERT(tor->session->am_in_session_thread());
auto const lock = tor->unique_lock();
if (tor->is_deleting_)
{
return;
}
tor->session->verify_remove(tor);
session->verify_remove(tor);
if (!tor->has_metainfo())
{
@ -1637,7 +1632,7 @@ void tr_torrentVerify(tr_torrent* tor)
tor->start_when_stable_ = false;
}
tor->session->verify_add(tor);
session->verify_add(tor);
});
}