diff --git a/src/policy.cpp b/src/policy.cpp index 36166255b..d7052b8b1 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -817,6 +817,9 @@ namespace libtorrent return true; } + // it's important that we don't dereference + // p here, since it is allowed to be a dangling + // pointer. see smart_ban.cpp bool policy::has_peer(policy::peer const* p) const { // find p in m_peers diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index cfc3ba80c..1f6e6ae01 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -196,6 +196,10 @@ namespace libtorrent { namespace // from the first time it sent it // at least one of them must be bad + // verify that this is not a dangling pointer + // if the pointer is in the policy's list, it + // still live, if it's not, it has been removed + // and we can't use this pointer if (!m_torrent.get_policy().has_peer(p)) return; #ifdef TORRENT_LOGGING