Fixup: Handle patterns without family

Pointed out by Akira Tagoh.
This commit is contained in:
Matthias Clasen 2020-08-25 07:26:32 -04:00
parent 51d40491fc
commit e117d6768c
1 changed files with 20 additions and 17 deletions

View File

@ -525,25 +525,28 @@ FcCompareDataInit (FcPattern *pat,
free);
elt = FcPatternObjectFindElt (pat, FC_FAMILY_OBJECT);
for (l = FcPatternEltValues(elt), i = 0; l; l = FcValueListNext(l), i++)
if (elt)
{
key = FcValueString (&l->value);
if (!FcHashTableFind (table, key, (void **)&e))
for (l = FcPatternEltValues(elt), i = 0; l; l = FcValueListNext(l), i++)
{
e = malloc (sizeof (FamilyEntry));
e->strong_value = 1e99;
e->weak_value = 1e99;
FcHashTableAdd (table, (void *)key, e);
}
if (l->binding == FcValueBindingWeak)
{
if (i < e->weak_value)
e->weak_value = i;
}
else
{
if (i < e->strong_value)
e->strong_value = i;
key = FcValueString (&l->value);
if (!FcHashTableFind (table, key, (void **)&e))
{
e = malloc (sizeof (FamilyEntry));
e->strong_value = 1e99;
e->weak_value = 1e99;
FcHashTableAdd (table, (void *)key, e);
}
if (l->binding == FcValueBindingWeak)
{
if (i < e->weak_value)
e->weak_value = i;
}
else
{
if (i < e->strong_value)
e->strong_value = i;
}
}
}