]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/MDSDaemon.cc: fix resource leak in MDSDaemon
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 21 Aug 2015 14:11:16 +0000 (16:11 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 10 Sep 2015 17:29:20 +0000 (19:29 +0200)
Delete mdsmap in descructor. Remove not needed checks for
mds_rank and objecter before call delete since the C++ standard
allows the deletion of pointer with NULL-value. The check is
redundant.

Fix for:
CID 1316224 (#1 of 1): Resource leak in object (CTOR_DTOR_LEAK)
1. alloc_new: Allocating memory by calling new MDSMap.
2. var_assign: Assigning: this->mdsmap = new MDSMap.
3. ctor_dtor_leak: The constructor allocates field mdsmap of MDSDaemon
   but the destructor and whatever functions it calls do not free it.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/mds/MDSDaemon.cc

index 7d23722792c5a934218c29830192ecf8f2e5ef05..793dab40de319c8c8e26eba886ab8a464c7e0ea5 100644 (file)
@@ -139,8 +139,12 @@ MDSDaemon::MDSDaemon(const std::string &n, Messenger *m, MonClient *mc) :
 MDSDaemon::~MDSDaemon() {
   Mutex::Locker lock(mds_lock);
 
-  if (mds_rank) {delete mds_rank ; mds_rank = NULL; }
-  if (objecter) {delete objecter ; objecter = NULL; }
+  delete mds_rank; 
+  mds_rank = NULL; 
+  delete objecter; 
+  objecter = NULL;
+  delete mdsmap;
+  mdsmap = NULL;
 
   delete authorize_handler_service_registry;
   delete authorize_handler_cluster_registry;