diff options
author | sfan5 <sfan5@live.de> | 2021-06-01 19:45:45 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-06-01 19:47:41 +0200 |
commit | e15cae9fa0f99f597f349a7ba07d149cd91cc2d8 (patch) | |
tree | 7af986df63c51cfd3595fc35d34f6536c65c4503 | |
parent | c9144ae5e22ee041fed2512cd3055608c6e9a4bc (diff) | |
download | minetest-e15cae9fa0f99f597f349a7ba07d149cd91cc2d8.tar.gz minetest-e15cae9fa0f99f597f349a7ba07d149cd91cc2d8.tar.bz2 minetest-e15cae9fa0f99f597f349a7ba07d149cd91cc2d8.zip |
fontengine: Fix crash loading PNG/XML fonts from paths without dot
fixes #11096
-rw-r--r-- | src/client/fontengine.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/client/fontengine.cpp b/src/client/fontengine.cpp index 0382c2f18..f64315db4 100644 --- a/src/client/fontengine.cpp +++ b/src/client/fontengine.cpp @@ -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 |