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

fix: keep peer io alive inside utp callback (#6507)

This commit is contained in:
Yat Ho 2024-01-21 08:09:28 +08:00 committed by GitHub
parent 468de87076
commit a1160f1556
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -725,6 +725,11 @@ void tr_peerIo::utp_init([[maybe_unused]] struct_utp_context* ctx)
{
if (auto* const io = static_cast<tr_peerIo*>(utp_get_userdata(args->socket)); io != nullptr)
{
// The peer io object can destruct inside can_read_wrapper(), so keep
// it alive for the duration of this code block. This can happen when
// a BT handshake did not complete successfully for example.
auto const keep_alive = io->shared_from_this();
io->inbuf_.add(args->buf, args->len);
io->set_enabled(TR_DOWN, true);
io->can_read_wrapper();