Fix small memory error (tried to free argv); use basename and dirname

correctly (they can modify their arguments).
This commit is contained in:
Patrick Lam 2005-11-01 05:52:28 +00:00
parent e77c17184a
commit d6946c1a11
3 changed files with 9 additions and 4 deletions

View File

@ -1,3 +1,10 @@
2005-10-31 Patrick Lam <plam@mit.edu>
* 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 <plam@mit.edu>
* fc-cat/fc-cat.c:
* src/fccache.c:

View File

@ -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);

View File

@ -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);