Fix 09f585b: Crash if font name ends with comma or comma and whitespace on Linux. (#11838)

This commit is contained in:
Peter Nelson 2024-01-19 08:03:32 +00:00 committed by GitHub
parent 1c694e433d
commit 6a2c37b4ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -34,6 +34,8 @@ static std::tuple<std::string, std::string> SplitFontFamilyAndStyle(std::string_
if (separator == std::string_view::npos) return { std::string(font_name), std::string() };
auto begin = font_name.find_first_not_of("\t ", separator + 1);
if (begin == std::string_view::npos) return { std::string(font_name.substr(0, separator)), std::string() };
return { std::string(font_name.substr(0, separator)), std::string(font_name.substr(begin)) };
}