From 86cf8275224536a7ca77eaf8a6e59951b3f25261 Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Thu, 26 May 2022 22:25:06 +0530 Subject: [PATCH] rgw: Avoid dereferencing nullptr while configuring bucket sync policy While configuring bucket sync policy, in "rgw_sync_bucket_entities::set_bucket()", there could be a case where in bucket doesnt contain any value but is still being dereferenced. This commit fixes the same. Signed-off-by: Soumya Koduri --- src/rgw/rgw_sync_policy.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rgw/rgw_sync_policy.cc b/src/rgw/rgw_sync_policy.cc index b7a8adafcee..cf28d5eecc4 100644 --- a/src/rgw/rgw_sync_policy.cc +++ b/src/rgw/rgw_sync_policy.cc @@ -258,6 +258,10 @@ void rgw_sync_bucket_entities::set_bucket(std::optional tenant, bucket.emplace(); } + if (!bucket) { + return; + } + set_bucket_field(tenant, &bucket->tenant); set_bucket_field(bucket_name, &bucket->name); set_bucket_field(bucket_id, &bucket->bucket_id); -- 2.47.3