[Base] Fix edge case in UTF-8 fnfp/fbp.
[Base] Fix edge case in UTF-8 find_name_from_path/find_base_path with strings that consist of only a separator.
This commit is contained in:
@@ -560,6 +560,9 @@ std::string find_name_from_path(const std::string_view path,
|
|||||||
// path is padded with separator
|
// path is padded with separator
|
||||||
size_t padding = 0;
|
size_t padding = 0;
|
||||||
if (*it == uint32_t(separator)) {
|
if (*it == uint32_t(separator)) {
|
||||||
|
if (it == begin) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
--it;
|
--it;
|
||||||
--end;
|
--end;
|
||||||
padding = 1;
|
padding = 1;
|
||||||
@@ -626,7 +629,11 @@ std::string find_base_path(const std::string_view path, char32_t separator) {
|
|||||||
auto it = end;
|
auto it = end;
|
||||||
--it;
|
--it;
|
||||||
|
|
||||||
|
// skip trailing separator
|
||||||
if (*it == uint32_t(separator)) {
|
if (*it == uint32_t(separator)) {
|
||||||
|
if (it == begin) {
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
--it;
|
--it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user