From: Patrick Lam Date: Wed, 2 Nov 2005 15:29:53 +0000 (+0000) Subject: Don't zero out full names for FC_REF_CONSTANT fonts; also, duplicate full X-Git-Tag: fc-2_3_92~5 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=d7b3ac63675983c92092703c9c7da0d9e3c0b2ad;p=fontconfig.git Don't zero out full names for FC_REF_CONSTANT fonts; also, duplicate full names when transferring, and free full names when freeing the associated font. Reported by Jinghua Luo. --- diff --git a/ChangeLog b/ChangeLog index 5814892..7c45d3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-11-02 Patrick Lam + * src/fcpat.c (FcPatternDestroy, FcPatternTransferFullName): + + Don't zero out full names for FC_REF_CONSTANT fonts; + also, duplicate full names when transferring, and free + full names when freeing the associated font. + Reported by Jinghua Luo. + 2005-11-02 Patrick Lam * fc-cache/fc-cache.c (scanDirs): * src/fcpat.c (FcValueListSerialize): diff --git a/src/fcpat.c b/src/fcpat.c index fa63ea3..4dc5e4b 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -39,6 +39,13 @@ FcPatternFindFullFname (const FcPattern *p); static FcPatternEltPtr FcPatternEltPtrCreateDynamic (FcPatternElt * e); +/* If you are trying to duplicate an FcPattern which will be used for + * rendering, be aware that (internally) you also have to use + * FcPatternTransferFullFname to transfer the associated filename. If + * you are copying the font (externally) using FcPatternGetString, + * then everything's fine; this caveat only applies if you're copying + * the bits individually. */ + FcPattern * FcPatternCreate (void) { @@ -297,12 +304,15 @@ FcPatternDestroy (FcPattern *p) { int i; - if (FcPatternFindFullFname (p)) - FcPatternAddFullFname (p, 0); - if (p->ref == FC_REF_CONSTANT || --p->ref > 0) return; + if (FcPatternFindFullFname (p)) + { + FcStrFree (FcPatternFindFullFname (p)); + FcPatternAddFullFname (p, 0); + } + for (i = 0; i < p->num; i++) FcValueListDestroy ((FcPatternEltU(p->elts)+i)->values); @@ -1993,5 +2003,5 @@ FcPatternTransferFullFname (const FcPattern *new, const FcPattern *orig) { FcChar8 * s; FcPatternGetString (orig, FC_FILE, 0, &s); - FcPatternAddFullFname (new, FcPatternFindFullFname(orig)); + FcPatternAddFullFname (new, FcStrCopy (FcPatternFindFullFname(orig))); }