[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:
gibbed 2021-05-02 08:08:21 -05:00 committed by Rick Gibbed
parent f868a10649
commit de3825274e
1 changed files with 7 additions and 0 deletions

View File

@ -560,6 +560,9 @@ std::string find_name_from_path(const std::string_view path,
// path is padded with separator
size_t padding = 0;
if (*it == uint32_t(separator)) {
if (it == begin) {
return std::string();
}
--it;
--end;
padding = 1;
@ -626,7 +629,11 @@ std::string find_base_path(const std::string_view path, char32_t separator) {
auto it = end;
--it;
// skip trailing separator
if (*it == uint32_t(separator)) {
if (it == begin) {
return std::string();
}
--it;
}