Fix a crash when non-builtin objects are edited
This commit is contained in:
parent
6c664d533d
commit
223c1384c9
28
src/fccfg.c
28
src/fccfg.c
|
@ -649,8 +649,10 @@ FcConfigAddRule (FcConfig *config,
|
||||||
{
|
{
|
||||||
FcSubst *subst, **prev;
|
FcSubst *subst, **prev;
|
||||||
FcRule *r;
|
FcRule *r;
|
||||||
int num;
|
int n = 0;
|
||||||
|
|
||||||
|
if (!rule)
|
||||||
|
return FcFalse;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case FcMatchPattern:
|
case FcMatchPattern:
|
||||||
prev = &config->substPattern;
|
prev = &config->substPattern;
|
||||||
|
@ -671,7 +673,6 @@ FcConfigAddRule (FcConfig *config,
|
||||||
*prev = subst;
|
*prev = subst;
|
||||||
subst->next = NULL;
|
subst->next = NULL;
|
||||||
subst->rule = rule;
|
subst->rule = rule;
|
||||||
num = 0;
|
|
||||||
for (r = rule; r; r = r->next)
|
for (r = rule; r; r = r->next)
|
||||||
{
|
{
|
||||||
switch (r->type)
|
switch (r->type)
|
||||||
|
@ -680,19 +681,21 @@ FcConfigAddRule (FcConfig *config,
|
||||||
if (r->u.test &&
|
if (r->u.test &&
|
||||||
r->u.test->kind == FcMatchDefault)
|
r->u.test->kind == FcMatchDefault)
|
||||||
r->u.test->kind = kind;
|
r->u.test->kind = kind;
|
||||||
if (r->u.test->object > FC_MAX_BASE_OBJECT)
|
|
||||||
num++;
|
if (n < r->u.test->object)
|
||||||
|
n = r->u.test->object;
|
||||||
break;
|
break;
|
||||||
case FcRuleEdit:
|
case FcRuleEdit:
|
||||||
if (r->u.edit->object > FC_MAX_BASE_OBJECT)
|
if (n < r->u.edit->object)
|
||||||
num++;
|
n = r->u.edit->object;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (config->maxObjects < num)
|
n = FC_OBJ_ID (n) - FC_MAX_BASE_OBJECT;
|
||||||
config->maxObjects = num;
|
if (config->maxObjects < n)
|
||||||
|
config->maxObjects = n;
|
||||||
if (FcDebug () & FC_DBG_EDIT)
|
if (FcDebug () & FC_DBG_EDIT)
|
||||||
{
|
{
|
||||||
printf ("Add Subst ");
|
printf ("Add Subst ");
|
||||||
|
@ -701,11 +704,6 @@ FcConfigAddRule (FcConfig *config,
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct _FcSubState {
|
|
||||||
FcPatternElt *elt;
|
|
||||||
FcValueList *value;
|
|
||||||
} FcSubState;
|
|
||||||
|
|
||||||
static FcValue
|
static FcValue
|
||||||
FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
|
FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
|
||||||
{
|
{
|
||||||
|
@ -1503,8 +1501,6 @@ FcConfigSubstituteWithPat (FcConfig *config,
|
||||||
int i, nobjs;
|
int i, nobjs;
|
||||||
FcBool retval = FcTrue;
|
FcBool retval = FcTrue;
|
||||||
|
|
||||||
#define FC_OBJ_ID(_n_) ((_n_) > FC_MAX_BASE_OBJECT ? ((_n_) - FC_EXT_OBJ_INDEX) : (_n_))
|
|
||||||
|
|
||||||
if (!config)
|
if (!config)
|
||||||
{
|
{
|
||||||
config = FcConfigGetCurrent ();
|
config = FcConfigGetCurrent ();
|
||||||
|
@ -1745,8 +1741,6 @@ bail1:
|
||||||
if (value)
|
if (value)
|
||||||
free (value);
|
free (value);
|
||||||
|
|
||||||
#undef FC_OBJ_ID
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,11 @@ typedef struct _FcValueList {
|
||||||
|
|
||||||
typedef int FcObject;
|
typedef int FcObject;
|
||||||
|
|
||||||
/* The 1000 is to leave some room for future added internal objects, such
|
/* The 1024 is to leave some room for future added internal objects, such
|
||||||
* that caches from newer fontconfig can still be used with older fontconfig
|
* that caches from newer fontconfig can still be used with older fontconfig
|
||||||
* without getting confused. */
|
* without getting confused. */
|
||||||
#define FC_EXT_OBJ_INDEX 1000
|
#define FC_EXT_OBJ_INDEX 1024
|
||||||
|
#define FC_OBJ_ID(_n_) ((_n_) & (~FC_EXT_OBJ_INDEX))
|
||||||
|
|
||||||
typedef struct _FcPatternElt *FcPatternEltPtr;
|
typedef struct _FcPatternElt *FcPatternEltPtr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue