From 42eac2ee3cc2b5a66cb8401b13965ea0844d47cf Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 15 Jul 2018 11:55:51 +0800 Subject: [PATCH] Simplify code This avoids "deferencing null pointer" warning from static analyzers. --- src/base/bittorrent/session.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index a39fc748b..c8c17dffc 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -2204,8 +2204,8 @@ bool Session::addTorrent_impl(CreateTorrentParams params, const MagnetUri &magne // processed or adding to session if (m_addingTorrents.contains(hash) || m_loadedMetadata.contains(hash)) return false; - if (m_torrents.contains(hash)) { - TorrentHandle *const torrent = m_torrents.value(hash); + TorrentHandle *const torrent = m_torrents.value(hash); + if (torrent) { if (torrent->isPrivate() || (!fromMagnetUri && torrentInfo.isPrivate())) return false; torrent->addTrackers(fromMagnetUri ? magnetUri.trackers() : torrentInfo.trackers());