]> granicus.if.org Git - libass/commitdiff
Check return value of add_face.
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Thu, 25 Oct 2007 21:19:20 +0000 (21:19 +0000)
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Thu, 25 Oct 2007 21:19:20 +0000 (21:19 +0000)
This fixes segfault when reselecting fonts and the new font could not be
loaded (because of a bad font file, or too many font faces already loaded).
Patch by Glen Nakamura, glen at imodulo dot com.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24855 b3059339-0415-0410-9bf9-f77b7e298cf2

libass/ass_font.c

index c434da7ca66abdda6ddf1ced8eae547dfd67b164..3ae6d716e55bd66e90a6eafb5c58e1f7272b00ba 100644 (file)
@@ -294,12 +294,14 @@ FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch
                mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_GlyphNotFoundReselectingFont,
                       ch, font->desc.family, font->desc.bold, font->desc.italic);
                face_idx = add_face(fontconfig_priv, font, ch);
+               if (face_idx >= 0) {
                face = font->faces[face_idx];
                index = FT_Get_Char_Index(face, ch);
                if (index == 0) {
                        mp_msg(MSGT_ASS, MSGL_ERR, MSGTR_LIBASS_GlyphNotFound,
                               ch, font->desc.family, font->desc.bold, font->desc.italic);
                }
+               }
        }
 #endif