From 5bb5da4c4a34ca7c0a7c513e38829f69654f9962 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 1 Jan 2013 20:09:08 -0600 Subject: [PATCH] Refuse to set value to unsupported types during config too --- src/fccfg.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) 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 ... */ -- 2.7.4