]> granicus.if.org Git - libass/commitdiff
Fix fontconfig disabled at runtime
authorGrigori Goronzy <greg@blackbox>
Wed, 16 Feb 2011 19:31:15 +0000 (20:31 +0100)
committerGrigori Goronzy <greg@blackbox>
Wed, 16 Feb 2011 19:31:15 +0000 (20:31 +0100)
MPlayer is able to use this configuration with the -nofontconfig flag;
this fixes crashes in case no font is available. Fixes a crash at uninit
as well.

libass/ass_drawing.c
libass/ass_fontconfig.c

index 93cc458d1683e5ad97d850b105f5fa43762b173c..940c66b02a694f19aac2516da548b4d318172626 100644 (file)
@@ -118,9 +118,10 @@ static void drawing_finish(ASS_Drawing *drawing, int raw_mode)
     // Close the last contour
     drawing_close_shape(drawing);
 
-    ass_msg(drawing->library, MSGL_V,
-            "Parsed drawing with %d points and %d contours", ol->n_points,
-            ol->n_contours);
+    if (drawing->library)
+        ass_msg(drawing->library, MSGL_V,
+                "Parsed drawing with %d points and %d contours", ol->n_points,
+                ol->n_contours);
 
     if (raw_mode)
         return;
@@ -367,7 +368,8 @@ ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font,
     drawing->fontconfig_priv = fontconfig_priv;
     drawing->font = font;
     drawing->ftlibrary = lib;
-    drawing->library = font->library;
+    if (font)
+        drawing->library = font->library;
 
     drawing->scale_x = 1.;
     drawing->scale_y = 1.;
index 2571739ff219f67289763dbb6e22709e153a271d..33ef976fa2bfc2093b946532ae308bbc31265de1 100644 (file)
@@ -522,7 +522,8 @@ void fontconfig_done(FCInstance *priv)
 
     if (priv) {
 #ifdef CONFIG_FONTCONFIG
-        FcConfigDestroy(priv->config);
+        if (priv->config)
+            FcConfigDestroy(priv->config);
 #endif
         free(priv->path_default);
         free(priv->family_default);