From: Patrick Lam Date: Tue, 1 Nov 2005 05:52:28 +0000 (+0000) Subject: Fix small memory error (tried to free argv); use basename and dirname X-Git-Tag: fc-2_3_92~11 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=d6946c1a11695eb55a3fe60db5480df94570b1ba;p=fontconfig.git Fix small memory error (tried to free argv); use basename and dirname correctly (they can modify their arguments). --- diff --git a/ChangeLog b/ChangeLog index 6379c57..783603c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-10-31 Patrick Lam + * fc-cat/fc-cat.c (FcCacheFileRead, main): + * src/fcfreetype.c (FcFreeTypeQuery): + + Fix small memory error (tried to free argv); use basename and + dirname correctly (they can modify their arguments). + 2005-10-31 Patrick Lam * fc-cat/fc-cat.c: * src/fccache.c: diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c index a392327..4f5b71d 100644 --- a/fc-cat/fc-cat.c +++ b/fc-cat/fc-cat.c @@ -198,13 +198,11 @@ FcCacheFileRead (FcFontSet * set, FcStrSet *dirs, char * dir, char *cache_file) goto bail1; close(fd); - free (cache_file); return FcTrue; bail1: close (fd); bail: - free (cache_file); return FcFalse; } @@ -327,7 +325,7 @@ main (int argc, char **argv) i = 1; #endif - if (FcCacheFileRead (fs, dirs, dirname (argv[i]), argv[i])) + if (FcCacheFileRead (fs, dirs, dirname (strdup(argv[i])), argv[i])) FcCachePrintSet (fs, dirs, argv[i]); FcStrSetDestroy (dirs); diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 8a42fdb..9872836 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -1288,7 +1288,7 @@ FcFreeTypeQuery (const FcChar8 *file, printf ("Saving unique fullname %s\n", full); } - if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)file))) + if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)FcStrCopy(file)))) goto bail1; FcPatternAddFullFname (pat, (const char *)file);