From 5ecebf2394db0a378efb3420a9f2bac25992635c Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 7 Mar 2022 14:22:21 -0500 Subject: [PATCH] rgw: fix leak of RGWBucketList memory (octopus only) 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 --- src/rgw/rgw_sal.cc | 6 ++++++ src/rgw/rgw_sal.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 53079f66a783..9f1c7dc8e593 100644 --- a/src/rgw/rgw_sal.cc +++ b/src/rgw/rgw_sal.cc @@ -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, diff --git a/src/rgw/rgw_sal.h b/src/rgw/rgw_sal.h index 542844d03924..e4e7081b8a05 100644 --- a/src/rgw/rgw_sal.h +++ b/src/rgw/rgw_sal.h @@ -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 { -- 2.47.3