]> git.wh0rd.org Git - fontconfig.git/commitdiff
Fix memory leaks reported by Ronny V. Vindenes.
authorPatrick Lam <plam@MIT.EDU>
Wed, 25 Jan 2006 02:33:46 +0000 (02:33 +0000)
committerPatrick Lam <plam@MIT.EDU>
Wed, 25 Jan 2006 02:33:46 +0000 (02:33 +0000)
ChangeLog
src/fccache.c
src/fcfreetype.c

index 98e404c51cf9acb932b1b98280212faf880014cb..b4c3c8a8c5b44571f47475767c9e2cf459442d51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-24  Patrick Lam  <plam@mit.edu>
+       * src/fccache.c (FcDirCacheUnlink, FcDirCacheWrite):
+       * src/fcfreetype.c (FcFreeTypeQuery):
+
+       Fix memory leaks reported by Ronny V. Vindenes.
+
 2006-01-19  Andreas Schwab  <schwab@suse.de>
        reviewed by: plam
 
index 10e65ddc0d2ce68546cc8a8b543f0f538edd8385..688da877ef1e66f45c2cb8a4e491498982389b65 100644 (file)
@@ -658,7 +658,7 @@ FcBool
 FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
 {
     char       *cache_file;
-    char       *cache_hashed;
+    char       *cache_hashed = 0;
     int                fd, collisions;
     struct stat        cache_stat;
     char       name_buf[FC_MAX_FILE_LEN];
@@ -677,6 +677,9 @@ FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
     fd = -1; collisions = 0;
     do
     {
+       if (cache_hashed)
+           FcStrFree ((FcChar8 *)cache_hashed);
+
        cache_hashed = FcDirCacheHashName (cache_file, collisions++);
        if (!cache_hashed)
            goto bail;
@@ -692,7 +695,10 @@ FcDirCacheUnlink (const FcChar8 *dir, FcConfig *config)
 
        FcCacheReadString (fd, name_buf, sizeof (name_buf));
        if (!strlen(name_buf))
+       {
+           FcStrFree ((FcChar8 *)cache_hashed);
            goto bail;
+       }
     } while (strcmp (name_buf, cache_file) != 0);
 
     FcStrFree ((FcChar8 *)cache_file);
@@ -1189,6 +1195,7 @@ FcDirCacheWrite (FcFontSet *set, FcStrSet *dirs, const FcChar8 *dir)
     if (ftruncate (fd, current_arch_start + truncate_to) == -1)
        goto bail5;
 
+    free (header);
     close(fd);
     if (!FcAtomicReplaceOrig(atomic))
         goto bail5;
index 0b976f70c85f763abb238fe876083ea702132e86..7f0af31937a6ab51e32cf62714e76115242abd37 100644 (file)
@@ -1000,6 +1000,7 @@ FcFreeTypeQuery (const FcChar8    *file,
     FcChar8        *family = 0;
 #endif
     FcChar8        *complex;
+    FcChar8        *file2;
     const FcChar8   *foundry = 0;
     int                    spacing;
     TT_OS2         *os2;
@@ -1280,8 +1281,13 @@ FcFreeTypeQuery (const FcChar8   *file,
                printf ("Saving unique fullname %s\n", full);
     }
 
-    if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)FcStrCopy(file))))
+    file2 = FcStrCopy (file);
+    if (!FcPatternAddString (pat, FC_FILE, (FcChar8 *)basename((char *)file2)))
+    {
+       FcStrFree (file2);
        goto bail1;
+    }
+    FcStrFree (file2);
 
     FcPatternAddFullFname (pat, (const char *)FcStrCopy (file));