diff --git a/libtorrent/include/libtorrent/intrusive_ptr_base.hpp b/libtorrent/include/libtorrent/intrusive_ptr_base.hpp index 98a1fed2e..5cccdf827 100644 --- a/libtorrent/include/libtorrent/intrusive_ptr_base.hpp +++ b/libtorrent/include/libtorrent/intrusive_ptr_base.hpp @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #define TORRENT_INTRUSIVE_PTR_BASE #include +#include #include "libtorrent/config.hpp" #include "libtorrent/assert.hpp" @@ -60,7 +61,7 @@ namespace libtorrent TORRENT_ASSERT(s->m_refs > 0); TORRENT_ASSERT(s != 0); if (--s->m_refs == 0) - delete static_cast(s); + boost::checked_delete(static_cast(s)); } boost::intrusive_ptr self() diff --git a/libtorrent/include/libtorrent/storage.hpp b/libtorrent/include/libtorrent/storage.hpp index 68a81c75b..a3f97b589 100755 --- a/libtorrent/include/libtorrent/storage.hpp +++ b/libtorrent/include/libtorrent/storage.hpp @@ -57,6 +57,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_request.hpp" #include "libtorrent/hasher.hpp" #include "libtorrent/config.hpp" +#include "libtorrent/buffer.hpp" namespace libtorrent { @@ -344,8 +345,8 @@ namespace libtorrent // used to move pieces while expanding // the storage from compact allocation // to full allocation - std::vector m_scratch_buffer; - std::vector m_scratch_buffer2; + buffer m_scratch_buffer; + buffer m_scratch_buffer2; // the piece that is in the scratch buffer int m_scratch_piece; diff --git a/libtorrent/src/broadcast_socket.cpp b/libtorrent/src/broadcast_socket.cpp index 4c2e9397c..a9d27eff4 100644 --- a/libtorrent/src/broadcast_socket.cpp +++ b/libtorrent/src/broadcast_socket.cpp @@ -190,6 +190,8 @@ namespace libtorrent void broadcast_socket::close() { + m_on_receive.clear(); + for (std::list::iterator i = m_sockets.begin() , end(m_sockets.end()); i != end; ++i) { diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index ea3214345..5fcaac51b 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -2122,8 +2122,8 @@ namespace detail entry session_impl::dht_state() const { - TORRENT_ASSERT(m_dht); mutex_t::scoped_lock l(m_mutex); + if (!m_dht) return entry(); return m_dht->state(); } diff --git a/libtorrent/src/storage.cpp b/libtorrent/src/storage.cpp index 58791572a..0468684f3 100755 --- a/libtorrent/src/storage.cpp +++ b/libtorrent/src/storage.cpp @@ -99,6 +99,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include "libtorrent/utf8.hpp" +#include "libtorrent/buffer.hpp" namespace libtorrent { @@ -386,7 +387,7 @@ namespace libtorrent file_pool& m_files; // temporary storage for moving pieces - std::vector m_scratch_buffer; + buffer m_scratch_buffer; }; sha1_hash storage::hash_for_slot(int slot, partial_hash& ph, int piece_size) @@ -468,14 +469,14 @@ namespace libtorrent void storage::release_files() { m_files.release(this); - std::vector().swap(m_scratch_buffer); + buffer().swap(m_scratch_buffer); } void storage::delete_files() { // make sure we don't have the files open m_files.release(this); - std::vector().swap(m_scratch_buffer); + buffer().swap(m_scratch_buffer); // delete the files from disk std::set directories; @@ -975,6 +976,7 @@ namespace libtorrent , m_storage_mode(storage_mode_sparse) , m_info(ti) , m_save_path(complete(save_path)) + , m_state(state_none) , m_current_slot(0) , m_out_of_place(false) , m_scratch_piece(-1) @@ -1622,8 +1624,8 @@ namespace libtorrent if (m_current_slot == m_info->num_pieces()) { m_state = state_create_files; - std::vector().swap(m_scratch_buffer); - std::vector().swap(m_scratch_buffer2); + buffer().swap(m_scratch_buffer); + buffer().swap(m_scratch_buffer2); if (m_storage_mode != storage_mode_compact) { std::vector().swap(m_piece_to_slot);