From 1f23976adab74e25ce06941692a881521885c6ee 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 --- 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 17dbe3d49c7..ae6ce016360 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" @@ -2162,7 +2163,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; @@ -2171,7 +2172,7 @@ public: if (ret < 0) { return ret; } - *phandle = (void *)info; + *phandle = (void *)info.release(); return 0; } @@ -2361,7 +2362,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; @@ -2370,7 +2371,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 0fa690b590f..ebe795e7d6f 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; }