]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix leak of RGWBucketList memory (octopus only) 45283/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 7 Mar 2022 19:22:21 +0000 (14:22 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 7 Mar 2022 19:22:23 +0000 (14:22 -0500)
this updates an earlier octopus-only fix,
0de02a88be0972c89ed2bb10dc438d080137bd18, to also free the RGWBucket*
in each map entry

this issue only exists on octopus, so this fix targets octopus directly
instead of cherry-picking from master

Fixes: https://tracker.ceph.com/issues/54482
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_sal.cc
src/rgw/rgw_sal.h

index 53079f66a783590795f7aaa6fd38ca30a813564a..9f1c7dc8e5938f4a9a6cf5c0ad07d8c862957ec7 100644 (file)
@@ -53,11 +53,17 @@ int RGWRadosUser::list_buckets(const string& marker, const string& end_marker,
 }
 
 RGWBucketList::~RGWBucketList()
+{
+  clear();
+}
+
+void RGWBucketList::clear()
 {
   for (auto itr = buckets.begin(); itr != buckets.end(); itr++) {
     delete itr->second;
   }
   buckets.clear();
+  truncated = false;
 }
 
 RGWBucket* RGWRadosUser::add_bucket(rgw_bucket& bucket,
index 542844d03924868770b2629e11559fafe7c25378..e4e7081b8a05a7a629120b3a18a400fdbc9aa769 100644 (file)
@@ -154,7 +154,7 @@ public:
     buckets[bucket->ent.bucket.name] = bucket;
   }
   size_t count() const { return buckets.size(); }
-  void clear() { buckets.clear(); truncated = false; }
+  void clear();
 }; // class RGWBucketList
 
 class RGWObject {