From: Ronen Friedman Date: Sun, 5 Jul 2026 12:46:48 +0000 (+0000) Subject: rgw/bucket_logging: fix dangling string_view from ternary temporary X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a5807c0878749edff5b66854bf63b206af7ddec1;p=ceph.git rgw/bucket_logging: fix dangling string_view from ternary temporary Clearing a compilation warning: The ternary operator created a temporary std::string to unify const std::string& and const char* branches, leaving the string_view pointing to a destroyed object. Replace with find() + if/else to assign directly from stable storage. Signed-off-by: Ronen Friedman --- diff --git a/src/rgw/rgw_bucket_logging.cc b/src/rgw/rgw_bucket_logging.cc index 3ca820ee2148..597584ce6f20 100644 --- a/src/rgw/rgw_bucket_logging.cc +++ b/src/rgw/rgw_bucket_logging.cc @@ -501,8 +501,12 @@ int log_record(rgw::sal::Driver* driver, input.user_agent = s->info.env->get("HTTP_USER_AGENT", "-"); input.ssl_cipher = s->info.env->get("SSL_CIPHER", "-"); input.tls_version = s->info.env->get("TLS_VERSION", "-"); - input.x_amz_id_2 = s->info.x_meta_map.contains("x-amz-id-2") ? - s->info.x_meta_map.at("x-amz-id-2") : "-"; + if (auto it = s->info.x_meta_map.find("x-amz-id-2"); + it != s->info.x_meta_map.end()) { + input.x_amz_id_2 = it->second; + } else { + input.x_amz_id_2 = "-"; + } input.http_ret = s->err.http_ret; input.err_code = s->err.err_code; input.content_length = s->content_length;