]> git.lizzy.rs Git - minetest.git/commitdiff
fontengine: Fix crash loading PNG/XML fonts from paths without dot
authorsfan5 <sfan5@live.de>
Tue, 1 Jun 2021 17:45:45 +0000 (19:45 +0200)
committersfan5 <sfan5@live.de>
Tue, 1 Jun 2021 17:47:41 +0000 (19:47 +0200)
fixes #11096

src/client/fontengine.cpp

index 0382c2f18e630d82d9f44b68b04c3a8c2aba7db5..f64315db476a9f3355f17cc7ebd8a1ca9689b28e 100644 (file)
@@ -342,8 +342,9 @@ gui::IGUIFont *FontEngine::initSimpleFont(const FontSpec &spec)
                        (spec.mode == FM_SimpleMono) ? "mono_font_path" : "font_path");
 
        size_t pos_dot = font_path.find_last_of('.');
-       std::string basename = font_path;
-       std::string ending = lowercase(font_path.substr(pos_dot));
+       std::string basename = font_path, ending;
+       if (pos_dot != std::string::npos)
+               ending = lowercase(font_path.substr(pos_dot));
 
        if (ending == ".ttf") {
                errorstream << "FontEngine: Found font \"" << font_path