From 298d63d47c4d7c2c39d0beb5c962933591aa8602 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 9 Sep 2021 21:36:47 +0800 Subject: [PATCH] Prevent self-assignment in assignment operator --- src/base/bittorrent/torrentinfo.cpp | 5 ++++- src/base/rss/rss_autodownloadrule.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/torrentinfo.cpp b/src/base/bittorrent/torrentinfo.cpp index aaccedac9..e67eb9e68 100644 --- a/src/base/bittorrent/torrentinfo.cpp +++ b/src/base/bittorrent/torrentinfo.cpp @@ -89,7 +89,10 @@ TorrentInfo::TorrentInfo(const TorrentInfo &other) TorrentInfo &TorrentInfo::operator=(const TorrentInfo &other) { - m_nativeInfo = other.m_nativeInfo; + if (this != &other) + { + m_nativeInfo = other.m_nativeInfo; + } return *this; } diff --git a/src/base/rss/rss_autodownloadrule.cpp b/src/base/rss/rss_autodownloadrule.cpp index ac47fbb53..2ec2727ca 100644 --- a/src/base/rss/rss_autodownloadrule.cpp +++ b/src/base/rss/rss_autodownloadrule.cpp @@ -442,7 +442,10 @@ bool AutoDownloadRule::accepts(const QVariantHash &articleData) AutoDownloadRule &AutoDownloadRule::operator=(const AutoDownloadRule &other) { - m_dataPtr = other.m_dataPtr; + if (this != &other) + { + m_dataPtr = other.m_dataPtr; + } return *this; }