From 7358dae49b328f5546d156246510601e2dd85d1c Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Thu, 3 Nov 2005 04:23:22 +0000 Subject: [PATCH] Fix warnings and embarrassing double-free error. --- ChangeLog | 7 +++++++ src/fcfreetype.c | 2 +- src/fcpat.c | 14 +++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6223c13..d4e3a88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-11-02 Patrick Lam + * src/fcfreetype.c (FcFreetypeQuery): + * src/fcpat.c (FcPatternDestroy, FcPatternDuplicate, + FcPatternTransferFullFname): + + Fix warnings and embarrassing double-free error. + 2005-11-02 Zhe Su reviewed by: plam diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 9872836..46dc5a4 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -1291,7 +1291,7 @@ FcFreeTypeQuery (const FcChar8 *file, if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)FcStrCopy(file)))) goto bail1; - FcPatternAddFullFname (pat, (const char *)file); + FcPatternAddFullFname (pat, (const char *)FcStrCopy (file)); if (!FcPatternAddInteger (pat, FC_INDEX, id)) goto bail1; diff --git a/src/fcpat.c b/src/fcpat.c index 4dc5e4b..295ed02 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -309,7 +309,7 @@ FcPatternDestroy (FcPattern *p) if (FcPatternFindFullFname (p)) { - FcStrFree (FcPatternFindFullFname (p)); + FcStrFree ((FcChar8 *)FcPatternFindFullFname (p)); FcPatternAddFullFname (p, 0); } @@ -1276,14 +1276,8 @@ FcPatternDuplicate (const FcPattern *orig) FcValueCanonicalize(&FcValueListPtrU(l)->value), FcTrue)) goto bail1; - - if (!strcmp ((char *)FcObjectPtrU((e + i)->object), FC_FILE)) - { - FcChar8 * s; - FcPatternGetString (orig, FC_FILE, 0, &s); - FcPatternAddFullFname (new, FcPatternFindFullFname(orig)); - } } + FcPatternTransferFullFname (orig, new); return new; @@ -2003,5 +1997,7 @@ FcPatternTransferFullFname (const FcPattern *new, const FcPattern *orig) { FcChar8 * s; FcPatternGetString (orig, FC_FILE, 0, &s); - FcPatternAddFullFname (new, FcStrCopy (FcPatternFindFullFname(orig))); + FcPatternAddFullFname (new, + (char *)FcStrCopy + ((FcChar8 *)FcPatternFindFullFname(orig))); } -- 2.39.5