From 313d26d22126f7bf545d7bb834b2098c341d1961 Mon Sep 17 00:00:00 2001
From: Cedric CAFFY <cedric.caffy@cern.ch>
Date: Fri, 6 Sep 2019 14:56:58 +0200
Subject: [PATCH] Corrected the memory leak in OStoreDBTest and
 SchedulerDatabaseTest

---
 catalogue/DummyCatalogue.hpp        | 1 -
 scheduler/OStoreDB/OStoreDBTest.cpp | 3 ++-
 scheduler/SchedulerDatabaseTest.cpp | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/catalogue/DummyCatalogue.hpp b/catalogue/DummyCatalogue.hpp
index a9778e562b..b314e32ed2 100644
--- a/catalogue/DummyCatalogue.hpp
+++ b/catalogue/DummyCatalogue.hpp
@@ -32,7 +32,6 @@ namespace catalogue {
 class DummyCatalogue: public Catalogue {
 public:
   DummyCatalogue() {}
-  DummyCatalogue(const cta::catalogue::DummyCatalogue*) {}
   virtual ~DummyCatalogue() { }
 
   void createActivitiesFairShareWeight(const common::dataStructures::SecurityIdentity& admin, const std::string& diskInstanceName, const std::string& acttivity, double weight, const std::string & comment) override { throw exception::Exception(std::string("In ")+__PRETTY_FUNCTION__+": not implemented"); }
diff --git a/scheduler/OStoreDB/OStoreDBTest.cpp b/scheduler/OStoreDB/OStoreDBTest.cpp
index f0d8eb2a4a..042245277e 100644
--- a/scheduler/OStoreDB/OStoreDBTest.cpp
+++ b/scheduler/OStoreDB/OStoreDBTest.cpp
@@ -64,7 +64,7 @@ public:
     // We do a deep reference to the member as the C++ compiler requires the function to be 
     // already defined if called implicitly.
     const auto &factory = GetParam().dbFactory;
-    m_catalogue = cta::make_unique<cta::catalogue::DummyCatalogue>(new cta::catalogue::DummyCatalogue);
+    m_catalogue = cta::make_unique<cta::catalogue::DummyCatalogue>();
     // Get the OStore DB from the factory.
     auto osdb = std::move(factory.create(m_catalogue));
     // Make sure the type of the SchedulerDatabase is correct (it should be an OStoreDBWrapperInterface).
@@ -75,6 +75,7 @@ public:
 
   virtual void TearDown() {
     m_db.reset();
+    m_catalogue.reset();
   }
 
   cta::objectstore::OStoreDBWrapperInterface &getDb() {
diff --git a/scheduler/SchedulerDatabaseTest.cpp b/scheduler/SchedulerDatabaseTest.cpp
index 21ba58a22a..178dd76f62 100644
--- a/scheduler/SchedulerDatabaseTest.cpp
+++ b/scheduler/SchedulerDatabaseTest.cpp
@@ -72,12 +72,13 @@ public:
     using namespace cta;
 
     const SchedulerDatabaseFactory &factory = GetParam().dbFactory;
-    m_catalogue = cta::make_unique<cta::catalogue::DummyCatalogue>(new cta::catalogue::DummyCatalogue);
+    m_catalogue = cta::make_unique<cta::catalogue::DummyCatalogue>();
     m_db.reset(factory.create(m_catalogue).release());
   }
 
   virtual void TearDown() {
     m_db.reset();
+    m_catalogue.reset();
   }
 
   cta::SchedulerDatabase &getDb() {
-- 
GitLab