From fbef47d3ec7202c9cbfb158ec2f39e767dfe6df6 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 2 Mar 2016 22:30:02 -0500 Subject: [PATCH] fix edge case in uTP stream when receiving a close-reason code --- src/utp_stream.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utp_stream.cpp b/src/utp_stream.cpp index f1311df1e..318bd8972 100644 --- a/src/utp_stream.cpp +++ b/src/utp_stream.cpp @@ -923,8 +923,11 @@ int utp_stream::read_buffer_size() const void utp_stream::on_close_reason(void* self, boost::uint16_t close_reason) { utp_stream* s = static_cast(self); - TORRENT_ASSERT(s->m_impl); - s->m_incoming_close_reason = close_reason; + + // it's possible the socket has been unlinked already, in which case m_impl + // will be NULL + if (s->m_impl) + s->m_incoming_close_reason = close_reason; } void utp_stream::on_read(void* self, size_t bytes_transferred