From 4a7d03d9b12b91ade60434321122c7e97e73813b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 8 Apr 2021 12:08:03 +0200 Subject: [PATCH] pnmtext: Fix loading an invalid font resulting in a crash Related to #1140 --- panda/src/pnmtext/freetypeFont.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/panda/src/pnmtext/freetypeFont.cxx b/panda/src/pnmtext/freetypeFont.cxx index f922943b7f..bab2734464 100644 --- a/panda/src/pnmtext/freetypeFont.cxx +++ b/panda/src/pnmtext/freetypeFont.cxx @@ -108,12 +108,14 @@ load_font(const Filename &font_filename, int face_index) { vfs->resolve_filename(path, get_model_path()); exists = vfs->read_file(path, _face->_font_data, true); if (exists) { - FT_Face face; + FT_Face face = 0; error = FT_New_Memory_Face(_face->_ft_library, (const FT_Byte *)_face->_font_data.data(), _face->_font_data.length(), face_index, &face); - _face->set_face(face); + if (face) { + _face->set_face(face); + } } bool okflag = false;