From f4427a582abea7a6294b96374a40516e678e02fa Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 14 Sep 2009 17:07:39 +0000 Subject: [PATCH] fixed disk buffer leak in smart_ban extension --- ChangeLog | 1 + src/smart_ban.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 04452a9a4..6ee3a45b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -87,6 +87,7 @@ release 0.14.6 * added --with-libgeoip option to configure script to allow building and linking against system wide library * fixed potential pure virtual function call in extensions on shutdown + * fixed disk buffer leak in smart_ban extension release 0.14.5 diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 5c7e5130e..8d2995aef 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -165,6 +165,10 @@ namespace libtorrent { namespace void on_read_failed_block(piece_block b, address a, int ret, disk_io_job const& j) { + aux::session_impl::mutex_t::scoped_lock l(m_torrent.session().m_mutex); + + disk_buffer_holder buffer(m_torrent.session(), j.buffer); + // ignore read errors if (ret != j.buffer_size) return; @@ -172,10 +176,6 @@ namespace libtorrent { namespace crc.update(j.buffer, j.buffer_size); crc.update((char const*)&m_salt, sizeof(m_salt)); - // since this callback is called directory from the disk io - // thread, the session mutex is not locked when we get here - aux::session_impl::mutex_t::scoped_lock l(m_torrent.session().m_mutex); - std::pair range = m_torrent.get_policy().find_peers(a); @@ -246,10 +246,10 @@ namespace libtorrent { namespace void on_read_ok_block(std::pair b, int ret, disk_io_job const& j) { - // since this callback is called directory from the disk io - // thread, the session mutex is not locked when we get here aux::session_impl::mutex_t::scoped_lock l(m_torrent.session().m_mutex); + disk_buffer_holder buffer(m_torrent.session(), j.buffer); + // ignore read errors if (ret != j.buffer_size) return;