From: Soumya Koduri Date: Thu, 26 May 2022 16:55:06 +0000 (+0530) Subject: rgw: Avoid dereferencing nullptr while configuring bucket sync policy X-Git-Tag: v16.2.11~260^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7019eef18323df73f261204a98bdfc081f2182ae;p=ceph.git 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 (cherry picked from commit 86cf8275224536a7ca77eaf8a6e59951b3f25261) --- diff --git a/src/rgw/rgw_sync_policy.cc b/src/rgw/rgw_sync_policy.cc index 6b5ecf414e0f..df20c46a44ef 100644 --- a/src/rgw/rgw_sync_policy.cc +++ b/src/rgw/rgw_sync_policy.cc @@ -256,6 +256,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);