From 0eed7ec56f7f9448a92867dfe1c481cce88a011d Mon Sep 17 00:00:00 2001 From: Adrien Beraud <adrien.beraud@savoirfairelinux.com> Date: Wed, 15 Mar 2017 01:02:46 +0100 Subject: [PATCH] certstore: fix memory leak Change-Id: I26c75c979d1fc0d2c18fdcecea55137319c4f8f4 --- src/security/certstore.cpp | 13 +++++++++++++ src/security/certstore.h | 9 +-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/security/certstore.cpp b/src/security/certstore.cpp index 3f09c59d90..877b0177d9 100644 --- a/src/security/certstore.cpp +++ b/src/security/certstore.cpp @@ -414,6 +414,19 @@ TrustStore::~TrustStore() gnutls_x509_trust_list_deinit(allowed_, false); } +TrustStore& +TrustStore::operator=(TrustStore&& o) +{ + unknownCertStatus_ = std::move(o.unknownCertStatus_); + certStatus_ = std::move(o.certStatus_); + revokedList_ = std::move(o.revokedList_); + if (allowed_) + gnutls_x509_trust_list_deinit(allowed_, false); + allowed_ = std::move(o.allowed_); + o.allowed_ = nullptr; + return *this; +} + bool TrustStore::addRevocationList(dht::crypto::RevocationList&& crl) { diff --git a/src/security/certstore.h b/src/security/certstore.h index 8d0f4ede0d..d978bdc606 100644 --- a/src/security/certstore.h +++ b/src/security/certstore.h @@ -119,14 +119,7 @@ public: o.allowed_ = nullptr; } - TrustStore& operator=(TrustStore&& o) { - unknownCertStatus_ = std::move(o.unknownCertStatus_); - certStatus_ = std::move(o.certStatus_); - revokedList_ = std::move(o.revokedList_), - allowed_ = std::move(o.allowed_); - o.allowed_ = nullptr; - return *this; - } + TrustStore& operator=(TrustStore&& o); enum class PermissionStatus { UNDEFINED = 0, -- GitLab