[MPlayer-dev-eng] [PATCH] ass fontconfig_init fall back to non-fontconfig on error

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Oct 31 13:40:55 CET 2008


Hello,
attached patch would make ass fontconfig_init fall back to the
non-fontconfig behaviour if e.g. the fontconfig configuration is broken.
Maybe that is a bad idea, but in that case the memoty leak for the
return 0 case (priv is not freed) still should be fixed.
Also, is it intentional that 0 is used instead of NULL for pointers in
some places and not in others? It's not incorrect but I find it very
ugly.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: ass_fontconfig.c
===================================================================
--- ass_fontconfig.c	(revision 27867)
+++ ass_fontconfig.c	(working copy)
@@ -407,10 +407,7 @@
 	if (!fc) {
 		mp_msg(MSGT_ASS, MSGL_WARN,
 		       MSGTR_LIBASS_FontconfigDisabledDefaultFontWillBeUsed);
-		priv->config = NULL;
-		priv->path_default = strdup(path);
-		priv->index_default = 0;
-		return priv;
+		goto exit;
 	}
 
 	rc = FcInit();
@@ -419,7 +416,7 @@
 	priv->config = FcConfigGetCurrent();
 	if (!priv->config) {
 		mp_msg(MSGT_ASS, MSGL_FATAL, MSGTR_LIBASS_FcInitLoadConfigAndFontsFailed);
-		return 0;
+		goto exit;
 	}
 
 	for (i = 0; i < library->num_fontdata; ++i)
@@ -468,6 +465,7 @@
 	}
 
 	priv->family_default = family ? strdup(family) : 0;
+exit:
 	priv->path_default = path ? strdup(path) : 0;
 	priv->index_default = 0;
 


More information about the MPlayer-dev-eng mailing list