1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-12 09:09:09 +00:00

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

This commit is contained in:
2024-01-19 00:55:32 +00:00
parent ae575a7a5b
commit d15fba439a

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() }; if (separator == std::string_view::npos) return { std::string(font_name), std::string() };
auto begin = font_name.find_first_not_of("\t ", separator + 1); 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)) }; return { std::string(font_name.substr(0, separator)), std::string(font_name.substr(begin)) };
} }