From f27738a7b942fd8a3d0c78befe0ce669e8b49ae3 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 13 Mar 2020 12:49:07 +0100 Subject: [PATCH] use unique_ptr instead of shared_ptr for torrent ssl context --- include/libtorrent/torrent.hpp | 2 +- src/torrent.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 7b664a735..bfa173584 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -1258,7 +1258,7 @@ namespace libtorrent { storage_holder m_storage; #ifdef TORRENT_USE_OPENSSL - std::shared_ptr m_ssl_ctx; + std::unique_ptr m_ssl_ctx; bool verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx); diff --git a/src/torrent.cpp b/src/torrent.cpp index 4f18d81e0..cdb3e59de 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1625,8 +1625,8 @@ bool is_downloading_state(int const st) // create the SSL context for this torrent. We need to // inject the root certificate, and no other, to // verify other peers against - std::shared_ptr ctx = std::make_shared( - aux::ssl_version(settings().get_int(settings_pack::ssl_version))); + std::unique_ptr ctx(new context( + aux::ssl_version(settings().get_int(settings_pack::ssl_version)))); if (!ctx) { @@ -1712,7 +1712,7 @@ bool is_downloading_state(int const st) ctx->load_verify_file(filename); #endif // if all went well, set the torrent ssl context to this one - m_ssl_ctx = ctx; + m_ssl_ctx = std::move(ctx); // tell the client we need a cert for this torrent alerts().emplace_alert(get_handle()); }