diff --git a/ChangeLog b/ChangeLog index ad6f28557..b1da58fea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * fixed a race condition bug in udp_tracker_connection that could + cause a crash. * fixed bug occuring when increasing the sequenced download threshold with max availability lower than previous threshold. * fixed an integer overflow bug occuring when built with gcc 4.1.x diff --git a/src/udp_tracker_connection.cpp b/src/udp_tracker_connection.cpp index db9bba50a..2a1e97d1a 100755 --- a/src/udp_tracker_connection.cpp +++ b/src/udp_tracker_connection.cpp @@ -101,6 +101,7 @@ namespace libtorrent , tcp::resolver::iterator i) try { if (error == asio::error::operation_aborted) return; + if (!m_socket) return; // the operation was aborted if (error || i == tcp::resolver::iterator()) { fail(-1, error.what()); @@ -138,6 +139,7 @@ namespace libtorrent + lexical_cast(tracker_req().info_hash) + "]"); } #endif + if (!m_socket) return; // the operation was aborted char send_buf[16]; char* ptr = send_buf; @@ -164,6 +166,7 @@ namespace libtorrent , std::size_t bytes_transferred) try { if (error == asio::error::operation_aborted) return; + if (!m_socket) return; // the operation was aborted if (error) { fail(-1, error.what()); @@ -248,6 +251,8 @@ namespace libtorrent if (m_transaction_id == 0) m_transaction_id = rand() ^ (rand() << 16); + if (!m_socket) return; // the operation was aborted + std::vector buf; std::back_insert_iterator > out(buf); @@ -302,6 +307,8 @@ namespace libtorrent if (m_transaction_id == 0) m_transaction_id = rand() ^ (rand() << 16); + if (!m_socket) return; // the operation was aborted + std::vector buf; std::back_insert_iterator > out(buf); @@ -325,6 +332,7 @@ namespace libtorrent , std::size_t bytes_transferred) try { if (error == asio::error::operation_aborted) return; + if (!m_socket) return; // the operation was aborted if (error) { fail(-1, error.what()); @@ -433,6 +441,7 @@ namespace libtorrent , std::size_t bytes_transferred) try { if (error == asio::error::operation_aborted) return; + if (!m_socket) return; // the operation was aborted if (error) { fail(-1, error.what());