summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2013-08-23 20:42:37 +0900
committerAkira TAGOH <akira@tagoh.org>2013-08-24 13:46:44 +0900
commit223c1384c98caaf9ba5d2cddf7465b7b3a82316b (patch)
tree784b7852147e96f542b73e3d51dc8dba6ebab2e6
parent6c664d533d242112c30e0d3b585e90a361a1b959 (diff)
Fix a crash when non-builtin objects are edited
-rw-r--r--src/fccfg.c28
-rw-r--r--src/fcint.h5
2 files changed, 14 insertions, 19 deletions
diff --git a/src/fccfg.c b/src/fccfg.c
index be738d53..d399f7fc 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -649,8 +649,10 @@ FcConfigAddRule (FcConfig *config,
{
FcSubst *subst, **prev;
FcRule *r;
- int num;
+ int n = 0;
+ if (!rule)
+ return FcFalse;
switch (kind) {
case FcMatchPattern:
prev = &config->substPattern;
@@ -671,7 +673,6 @@ FcConfigAddRule (FcConfig *config,
*prev = subst;
subst->next = NULL;
subst->rule = rule;
- num = 0;
for (r = rule; r; r = r->next)
{
switch (r->type)
@@ -680,19 +681,21 @@ FcConfigAddRule (FcConfig *config,
if (r->u.test &&
r->u.test->kind == FcMatchDefault)
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;
case FcRuleEdit:
- if (r->u.edit->object > FC_MAX_BASE_OBJECT)
- num++;
+ if (n < r->u.edit->object)
+ n = r->u.edit->object;
break;
default:
break;
}
}
- if (config->maxObjects < num)
- config->maxObjects = num;
+ n = FC_OBJ_ID (n) - FC_MAX_BASE_OBJECT;
+ if (config->maxObjects < n)
+ config->maxObjects = n;
if (FcDebug () & FC_DBG_EDIT)
{
printf ("Add Subst ");
@@ -701,11 +704,6 @@ FcConfigAddRule (FcConfig *config,
return FcTrue;
}
-typedef struct _FcSubState {
- FcPatternElt *elt;
- FcValueList *value;
-} FcSubState;
-
static FcValue
FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
{
@@ -1503,8 +1501,6 @@ FcConfigSubstituteWithPat (FcConfig *config,
int i, nobjs;
FcBool retval = FcTrue;
-#define FC_OBJ_ID(_n_) ((_n_) > FC_MAX_BASE_OBJECT ? ((_n_) - FC_EXT_OBJ_INDEX) : (_n_))
-
if (!config)
{
config = FcConfigGetCurrent ();
@@ -1745,8 +1741,6 @@ bail1:
if (value)
free (value);
-#undef FC_OBJ_ID
-
return retval;
}
diff --git a/src/fcint.h b/src/fcint.h
index ec0c6747..362ea6f9 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -174,10 +174,11 @@ typedef struct _FcValueList {
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
* 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;