diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index eb51cbe85ab..1af9612e888 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -283,15 +283,18 @@ void RGWListBucket_ObjStore_SWIFT::send_response() while (iter != objs.end() || pref_iter != common_prefixes.end()) { bool do_pref = false; bool do_objs = false; - rgw_obj_key key(iter->key); + rgw_obj_key key; + if (iter != objs.end()) { + key = iter->key; + } if (pref_iter == common_prefixes.end()) do_objs = true; else if (iter == objs.end()) do_pref = true; - else if (key.name.compare(pref_iter->first) == 0) { + else if (!key.empty() && key.name.compare(pref_iter->first) == 0) { do_objs = true; ++pref_iter; - } else if (key.name.compare(pref_iter->first) <= 0) + } else if (!key.empty() && key.name.compare(pref_iter->first) <= 0) do_objs = true; else do_pref = true;