From: Casey Bodley Date: Mon, 7 Mar 2022 19:22:21 +0000 (-0500) Subject: rgw: fix leak of RGWBucketList memory (octopus only) X-Git-Tag: v15.2.17~94^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F45283%2Fhead;p=ceph.git 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 --- diff --git a/src/rgw/rgw_sal.cc b/src/rgw/rgw_sal.cc index 53079f66a78..9f1c7dc8e59 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 542844d0392..e4e7081b8a0 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 {