From 508643cf1b5cf05f6bf651c1bbf7e5866e1874fa Mon Sep 17 00:00:00 2001 From: kgv Date: Thu, 3 Sep 2015 14:26:30 +0300 Subject: [PATCH] 0026611: Visualization, TKService - fix NULL-dereference in Font_FontMgr on broken font Check FT_Face::family_name for NULL during detection. Skip fonts without mandatory UNICODE charset in Font_FontMgr. Test case for issue CR26611 Drop the test case for issue CR26611 --- src/Font/Font_FontMgr.cxx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Font/Font_FontMgr.cxx b/src/Font/Font_FontMgr.cxx index 784ebd3ce8..583281121b 100644 --- a/src/Font/Font_FontMgr.cxx +++ b/src/Font/Font_FontMgr.cxx @@ -203,9 +203,14 @@ static Handle(Font_SystemFont) checkFont (const Handle(Font_FTLibrary)& theFTLib anAspect = Font_FA_Bold; } - Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aFontFace->family_name); - Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (theFontPath); - Handle(Font_SystemFont) aResult = new Font_SystemFont (aFontName, anAspect, aFontPath); + Handle(Font_SystemFont) aResult; + if (aFontFace->family_name != NULL // skip broken fonts (error in FreeType?) + && FT_Select_Charmap (aFontFace, ft_encoding_unicode) == 0) // Font_FTFont supports only UNICODE fonts + { + Handle(TCollection_HAsciiString) aFontName = new TCollection_HAsciiString (aFontFace->family_name); + Handle(TCollection_HAsciiString) aFontPath = new TCollection_HAsciiString (theFontPath); + aResult = new Font_SystemFont (aFontName, anAspect, aFontPath); + } FT_Done_Face (aFontFace);