diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index a1c756f30..da82bbf15 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2510,11 +2510,13 @@ namespace libtorrent void peer_connection::second_tick(float tick_interval) { - INVARIANT_CHECK; - ptime now(time_now()); boost::intrusive_ptr me(self()); + // the invariant check must be run before me is destructed + // in case the peer got disconnected + INVARIANT_CHECK; + boost::shared_ptr t = m_torrent.lock(); if (!t || m_disconnecting) {