mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 22:47:21 -06:00
Avoid dereferencing null pointers
PR #16896. Closes #16884 and similar issues.
This commit is contained in:
committed by
GitHub
parent
d7e9533e8c
commit
26e220e003
@@ -3982,7 +3982,8 @@ void Session::handleTorrentMetadataReceived(TorrentImpl *const torrent)
|
|||||||
if (!torrentExportDirectory().isEmpty())
|
if (!torrentExportDirectory().isEmpty())
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_LIBTORRENT2
|
#ifdef QBT_USES_LIBTORRENT2
|
||||||
const TorrentInfo torrentInfo {*torrent->nativeHandle().torrent_file_with_hashes()};
|
const std::shared_ptr<lt::torrent_info> completeTorrentInfo = torrent->nativeHandle().torrent_file_with_hashes();
|
||||||
|
const TorrentInfo torrentInfo {*(completeTorrentInfo ? completeTorrentInfo : torrent->nativeHandle().torrent_file())};
|
||||||
#else
|
#else
|
||||||
const TorrentInfo torrentInfo {*torrent->nativeHandle().torrent_file()};
|
const TorrentInfo torrentInfo {*torrent->nativeHandle().torrent_file()};
|
||||||
#endif
|
#endif
|
||||||
@@ -4038,7 +4039,8 @@ void Session::handleTorrentFinished(TorrentImpl *const torrent)
|
|||||||
if (!finishedTorrentExportDirectory().isEmpty())
|
if (!finishedTorrentExportDirectory().isEmpty())
|
||||||
{
|
{
|
||||||
#ifdef QBT_USES_LIBTORRENT2
|
#ifdef QBT_USES_LIBTORRENT2
|
||||||
const TorrentInfo torrentInfo {*torrent->nativeHandle().torrent_file_with_hashes()};
|
const std::shared_ptr<lt::torrent_info> completeTorrentInfo = torrent->nativeHandle().torrent_file_with_hashes();
|
||||||
|
const TorrentInfo torrentInfo {*(completeTorrentInfo ? completeTorrentInfo : torrent->nativeHandle().torrent_file())};
|
||||||
#else
|
#else
|
||||||
const TorrentInfo torrentInfo {*torrent->nativeHandle().torrent_file()};
|
const TorrentInfo torrentInfo {*torrent->nativeHandle().torrent_file()};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user