Refuse to set value to unsupported types during config too

This commit is contained in:
Behdad Esfahbod 2013-01-01 20:09:08 -06:00
parent 3878a12541
commit 5bb5da4c4a
1 changed files with 28 additions and 6 deletions

View File

@ -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 ... */