From dd860ab0c897ee6f3af8a549910e7ae0e3c4772c Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 30 Sep 2017 15:24:35 -0400 Subject: Guard against self-assignment Found with Sonar --- src/lib/filters/secqueue.cpp | 3 +++ src/lib/x509/x509_ext.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/lib/filters/secqueue.cpp b/src/lib/filters/secqueue.cpp index feaa26b4c..4b1a263a8 100644 --- a/src/lib/filters/secqueue.cpp +++ b/src/lib/filters/secqueue.cpp @@ -103,6 +103,9 @@ void SecureQueue::destroy() */ SecureQueue& SecureQueue::operator=(const SecureQueue& input) { + if(this == &input) + return *this; + destroy(); m_bytes_read = input.get_bytes_read(); m_head = m_tail = new SecureQueueNode; diff --git a/src/lib/x509/x509_ext.cpp b/src/lib/x509/x509_ext.cpp index d71af82b7..3141d3c44 100644 --- a/src/lib/x509/x509_ext.cpp +++ b/src/lib/x509/x509_ext.cpp @@ -57,6 +57,9 @@ Extensions::Extensions(const Extensions& extensions) : ASN1_Object() */ Extensions& Extensions::operator=(const Extensions& other) { + if(this == &other) + return *this; + m_extensions.clear(); for(size_t i = 0; i != other.m_extensions.size(); ++i) -- cgit v1.2.3