From 73ef8de0bf147a3ca670ab8a4b04ddaaf0ed5bfd Mon Sep 17 00:00:00 2001 From: Luo Kexue Date: Wed, 30 Aug 2017 09:32:18 +0800 Subject: [PATCH] rgw: fix resource leak in rgw_bucket.cc and rgw_user.cc Fixes: http://tracker.ceph.com/issues/21214 Signed-off-by: Luo Kexue (cherry picked from commit 1f23976adab74e25ce06941692a881521885c6ee) --- src/rgw/rgw_bucket.cc | 9 +++++---- src/rgw/rgw_user.cc | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index ff68a30af1e44..0da6dd587b672 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -12,6 +12,7 @@ #include "common/errno.h" #include "common/ceph_json.h" +#include "common/backport14.h" #include "rgw_rados.h" #include "rgw_acl.h" #include "rgw_acl_s3.h" @@ -2165,7 +2166,7 @@ public: } int list_keys_init(RGWRados *store, const string& marker, void **phandle) override { - list_keys_info *info = new list_keys_info; + auto info = ceph::make_unique(); info->store = store; @@ -2174,7 +2175,7 @@ public: if (ret < 0) { return ret; } - *phandle = (void *)info; + *phandle = (void *)info.release(); return 0; } @@ -2364,7 +2365,7 @@ public: } int list_keys_init(RGWRados *store, const string& marker, void **phandle) override { - list_keys_info *info = new list_keys_info; + auto info = ceph::make_unique(); info->store = store; @@ -2373,7 +2374,7 @@ public: if (ret < 0) { return ret; } - *phandle = (void *)info; + *phandle = (void *)info.release(); return 0; } diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index 0fa690b590ff4..ebe795e7d6f6b 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -11,6 +11,7 @@ #include "common/Formatter.h" #include "common/ceph_json.h" #include "common/RWLock.h" +#include "common/backport14.h" #include "rgw_rados.h" #include "rgw_acl.h" @@ -2774,7 +2775,7 @@ public: int list_keys_init(RGWRados *store, const string& marker, void **phandle) override { - list_keys_info *info = new list_keys_info; + auto info = ceph::make_unique(); info->store = store; @@ -2784,7 +2785,7 @@ public: return ret; } - *phandle = (void *)info; + *phandle = (void *)info.release(); return 0; } -- 2.39.5