From: Danny Al-Gaaf Date: Fri, 21 Aug 2015 14:11:16 +0000 (+0200) Subject: mds/MDSDaemon.cc: fix resource leak in MDSDaemon X-Git-Tag: v9.1.0~128^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e243aa84c0bc3e7c15178fc5a5a7499db3b88c37;p=ceph.git mds/MDSDaemon.cc: fix resource leak in MDSDaemon 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 --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 7d23722792c5..793dab40de31 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -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;