src/fccfg.c | 28 +++++++++++----------------- src/fcint.h | 5 +++-- src/fcxml.c | 7 ++++--- 3 files changed, 18 insertions(+), 22 deletions(-) New commits: commit 223c1384c98caaf9ba5d2cddf7465b7b3a82316b Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Aug 23 20:42:37 2013 +0900 Fix a crash when non-builtin objects are edited diff --git a/src/fccfg.c b/src/fccfg.c index be738d5..d399f7f 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 ec0c674..362ea6f 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; commit 6c664d533d242112c30e0d3b585e90a361a1b959 Author: Akira TAGOH <akira@xxxxxxxxx> Date: Fri Aug 23 19:58:43 2013 +0900 Fix a typo diff --git a/src/fcxml.c b/src/fcxml.c index 2cdf0ad..b464b4e 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -2509,7 +2509,6 @@ FcParseMatch (FcConfigParse *parse) { const FcChar8 *kind_name; FcMatchKind kind; - FcEdit *edit = 0; FcVStack *vstack; FcRule *rule = NULL, *r; @@ -2545,8 +2544,10 @@ FcParseMatch (FcConfigParse *parse) { FcConfigMessage (parse, FcSevereError, "<match target=\"scan\"> cannot edit user-defined object \"%s\"", - FcObjectName(edit->object)); - break; + FcObjectName(vstack->u.edit->object)); + if (rule) + FcRuleDestroy (rule); + return; } r = FcRuleCreate (FcRuleEdit, vstack->u.edit); if (rule) _______________________________________________ Fontconfig mailing list Fontconfig@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/fontconfig