From: Samuel Just Date: Sat, 21 Dec 2019 02:11:58 +0000 (+0000) Subject: rgw_kms: fix concat_url for empty url case X-Git-Tag: v15.1.0~91^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=181d991e53c13a1add675b58c22f8f5d79fc8768;p=ceph.git 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 --- diff --git a/src/rgw/rgw_kms.cc b/src/rgw/rgw_kms.cc index 098edeca51bd..dd6ba062d08d 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);