From 181d991e53c13a1add675b58c22f8f5d79fc8768 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Sat, 21 Dec 2019 02:11:58 +0000 Subject: [PATCH] rgw_kms: fix concat_url for empty url case Can't call back() on an empty string. Causes unittest_rgw_kms to fail when compiled with _GLIBCXX_ASSERTIONS. Signed-off-by: Samuel Just --- src/rgw/rgw_kms.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_kms.cc b/src/rgw/rgw_kms.cc index 098edeca51bdd..dd6ba062d08dd 100644 --- a/src/rgw/rgw_kms.cc +++ b/src/rgw/rgw_kms.cc @@ -25,10 +25,11 @@ using namespace rgw; * empty, the URL is not changed. */ static void concat_url(std::string &url, std::string path) { + bool url_has_slash = !url.empty() && url.back() == '/'; if (!path.empty()) { - if (url.back() == '/' && path.front() == '/') { + if (url_has_slash && path.front() == '/') { url.pop_back(); - } else if (url.back() != '/' && path.front() != '/') { + } else if (!url_has_slash && path.front() != '/') { url.push_back('/'); } url.append(path); -- 2.47.3