fontconfig: Branch 'master' - 5 commits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 src/fccfg.c    |   34 ++++++++++++++++++++++++++++------
 src/fcdbg.c    |   30 +++++++++++++++++++-----------
 src/fcformat.c |    7 +++++++
 src/fcint.h    |    5 ++++-
 src/fcpat.c    |   24 ++++++++++++------------
 5 files changed, 70 insertions(+), 30 deletions(-)

New commits:
commit 8198127b2525084bfe2378b83c185fa0da7f583b
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Tue Jan 1 20:20:31 2013 -0600

    Don't crash in FcPatternFormat() with NULL pattern

diff --git a/src/fcformat.c b/src/fcformat.c
index a8a1ad1..59f8681 100644
--- a/src/fcformat.c
+++ b/src/fcformat.c
@@ -1193,15 +1193,19 @@ FcPatternFormat (FcPattern *pat,
 {
     FcStrBuf        buf;
     FcChar8         buf_static[8192 - 1024];
+    FcPattern      *alloced = NULL;
     FcBool          ret;
 
     if (!pat)
-	return NULL;
+	alloced = pat = FcPatternCreate ();
 
     FcStrBufInit (&buf, buf_static, sizeof (buf_static));
 
     ret = FcPatternFormatToBuf (pat, format, &buf);
 
+    if (alloced)
+      FcPatternDestroy (alloced);
+
     if (ret)
 	return FcStrBufDone (&buf);
     else
commit c9581b47c4409612e8f2d4f67a402c566ba8330e
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Tue Jan 1 20:20:12 2013 -0600

    Don't crash in FcPatternDestroy with NULL pattern

diff --git a/src/fcpat.c b/src/fcpat.c
index 0aab7a0..d93eb73 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -359,6 +359,9 @@ FcPatternDestroy (FcPattern *p)
     int		    i;
     FcPatternElt    *elts;
 
+    if (!p)
+	return;
+
     if (p->ref == FC_REF_CONSTANT)
     {
 	FcCacheObjectDereference (p);
commit e7d3e2163280ffb970b60c6ed18e26325d0241e4
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Tue Jan 1 20:10:18 2013 -0600

    Add NULL check

diff --git a/src/fcformat.c b/src/fcformat.c
index a4c72ae..a8a1ad1 100644
--- a/src/fcformat.c
+++ b/src/fcformat.c
@@ -1195,6 +1195,9 @@ FcPatternFormat (FcPattern *pat,
     FcChar8         buf_static[8192 - 1024];
     FcBool          ret;
 
+    if (!pat)
+	return NULL;
+
     FcStrBufInit (&buf, buf_static, sizeof (buf_static));
 
     ret = FcPatternFormatToBuf (pat, format, &buf);
commit 5bb5da4c4a34ca7c0a7c513e38829f69654f9962
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Tue Jan 1 20:09:08 2013 -0600

    Refuse to set value to unsupported types during config too

diff --git a/src/fccfg.c b/src/fccfg.c
index 06f672b..ef5f4ff 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -1288,11 +1288,33 @@ static FcBool
 FcConfigAdd (FcValueListPtr *head,
 	     FcValueList    *position,
 	     FcBool	    append,
-	     FcValueList    *new)
+	     FcValueList    *new,
+	     FcObject        object)
 {
-    FcValueListPtr  *prev, last, v;
+    FcValueListPtr  *prev, l, last, v;
     FcValueBinding  sameBinding;
 
+    /*
+     * Make sure the stored type is valid for built-in objects
+     */
+    for (l = new; l != NULL; l = FcValueListNext (l))
+    {
+	if (!FcObjectValidType (object, l->value.type))
+	{
+	    fprintf (stderr,
+		     "Fontconfig warning: FcPattern object %s does not accept value", FcObjectName (object));
+	    FcValuePrintFile (stderr, l->value);
+	    fprintf (stderr, "\n");
+
+	    if (FcDebug () & FC_DBG_EDIT)
+	    {
+		printf ("Not adding\n");
+	    }
+
+	    return FcFalse;
+	}
+    }
+
     if (position)
 	sameBinding = position->binding;
     else
@@ -1387,7 +1409,7 @@ FcConfigPatternAdd (FcPattern	*p,
 
 	if (!e)
 	    return;
-	FcConfigAdd (&e->values, 0, append, list);
+	FcConfigAdd (&e->values, 0, append, list, object);
     }
 }
 
@@ -1579,7 +1601,7 @@ FcConfigSubstituteWithPat (FcConfig    *config,
 		    /*
 		     * Append the new list of values after the current value
 		     */
-		    FcConfigAdd (&st[i].elt->values, thisValue, FcTrue, l);
+		    FcConfigAdd (&st[i].elt->values, thisValue, FcTrue, l, e->object);
 		    /*
 		     * Delete the marked value
 		     */
@@ -1621,7 +1643,7 @@ FcConfigSubstituteWithPat (FcConfig    *config,
 	    case FcOpPrepend:
 		if (t)
 		{
-		    FcConfigAdd (&st[i].elt->values, st[i].value, FcFalse, l);
+		    FcConfigAdd (&st[i].elt->values, st[i].value, FcFalse, l, e->object);
 		    break;
 		}
 		/* fall through ... */
@@ -1631,7 +1653,7 @@ FcConfigSubstituteWithPat (FcConfig    *config,
 	    case FcOpAppend:
 		if (t)
 		{
-		    FcConfigAdd (&st[i].elt->values, st[i].value, FcTrue, l);
+		    FcConfigAdd (&st[i].elt->values, st[i].value, FcTrue, l, e->object);
 		    break;
 		}
 		/* fall through ... */
commit 3878a125410d1dd461aee1e40f9ac00d68be71f2
Author: Behdad Esfahbod <behdad@xxxxxxxxxx>
Date:   Tue Jan 1 19:52:14 2013 -0600

    Make FC_DBG_OBJTYPES debug messages into warnings
    
    And remove FC_DBG_OBJTYPES since it has no use now.

diff --git a/src/fcdbg.c b/src/fcdbg.c
index 20fc6c8..e8cbe32 100644
--- a/src/fcdbg.c
+++ b/src/fcdbg.c
@@ -27,44 +27,52 @@
 #include <stdlib.h>
 
 static void
-_FcValuePrint (const FcValue v)
+_FcValuePrintFile (FILE *f, const FcValue v)
 {
     switch (v.type) {
     case FcTypeVoid:
-	printf ("<void>");
+	fprintf (f, "<void>");
 	break;
     case FcTypeInteger:
-	printf ("%d(i)", v.u.i);
+	fprintf (f, "%d(i)", v.u.i);
 	break;
     case FcTypeDouble:
-	printf ("%g(f)", v.u.d);
+	fprintf (f, "%g(f)", v.u.d);
 	break;
     case FcTypeString:
-	printf ("\"%s\"", v.u.s);
+	fprintf (f, "\"%s\"", v.u.s);
 	break;
     case FcTypeBool:
-	printf ("%s", v.u.b ? "True" : "False");
+	fprintf (f, "%s", v.u.b ? "True" : "False");
 	break;
     case FcTypeMatrix:
-	printf ("[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
+	fprintf (f, "[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
 	break;
     case FcTypeCharSet:	/* XXX */
-	FcCharSetPrint (v.u.c);
+	if (f == stdout)
+	    FcCharSetPrint (v.u.c);
 	break;
     case FcTypeLangSet:
 	FcLangSetPrint (v.u.l);
 	break;
     case FcTypeFTFace:
-	printf ("face");
+	fprintf (f, "face");
 	break;
     }
 }
 
 void
+FcValuePrintFile (FILE *f, const FcValue v)
+{
+    fprintf (f, " ");
+    _FcValuePrintFile (f, v);
+}
+
+void
 FcValuePrint (const FcValue v)
 {
     printf (" ");
-    _FcValuePrint (v);
+    _FcValuePrintFile (stdout, v);
 }
 
 void
@@ -74,7 +82,7 @@ FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark)
 	printf (" [insert here] ");
     else
 	printf (" ");
-    _FcValuePrint (v);
+    _FcValuePrintFile (stdout, v);
 }
 
 static void
diff --git a/src/fcint.h b/src/fcint.h
index 68074f0..76b95ca 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -86,7 +86,6 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #define FC_DBG_SCANV	256
 #define FC_DBG_CONFIG	1024
 #define FC_DBG_LANGSET	2048
-#define FC_DBG_OBJTYPES	4096
 
 #define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
 #define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
@@ -703,6 +702,10 @@ FcPrivate FcChar16 *
 FcCharSetGetNumbers(const FcCharSet *c);
 
 /* fcdbg.c */
+
+FcPrivate void
+FcValuePrintFile (FILE *f, const FcValue v);
+
 FcPrivate void
 FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark);
 
diff --git a/src/fcpat.c b/src/fcpat.c
index 5d94295..0aab7a0 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -553,12 +553,10 @@ FcPatternObjectListAdd (FcPattern	*p,
     {
 	if (!FcObjectValidType (object, l->value.type))
 	{
-	    if (FcDebug() & FC_DBG_OBJTYPES)
-	    {
-		printf ("FcPattern object %s does not accept value ",
-			FcObjectName (object));
-		FcValuePrint (l->value);
-	    }
+	    fprintf (stderr,
+		     "Fontconfig warning: FcPattern object %s does not accept value", FcObjectName (object));
+	    FcValuePrintFile (stderr, l->value);
+	    fprintf (stderr, "\n");
 	    goto bail0;
 	}
     }
@@ -613,12 +611,11 @@ FcPatternObjectAddWithBinding  (FcPattern	*p,
      */
     if (!FcObjectValidType (object, value.type))
     {
-	if (FcDebug() & FC_DBG_OBJTYPES)
-	{
-	    printf ("FcPattern object %s does not accept value ",
-		    FcObjectName (object));
-	    FcValuePrint (value);
-	}
+	fprintf (stderr,
+		 "Fontconfig warning: FcPattern object %s does not accept value",
+		 FcObjectName (object));
+	FcValuePrintFile (stderr, value);
+	fprintf (stderr, "\n");
 	goto bail1;
     }
 
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig


[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux