Merge pull request #15444 from Chocobo1/guard

Prevent self-assignment in assignment operator
This commit is contained in:
Chocobo1
2021-09-12 12:56:17 +08:00
committed by GitHub
3 changed files with 10 additions and 6 deletions

View File

@@ -88,7 +88,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;
}

View File

@@ -440,7 +440,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;
}