Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: user <user@compaq>
To: Debian Bug Tracking System <[email protected]>
Subject: fbi: memory leaks detected
Bcc: user <user@compaq>
X-Reportbug-Version: 4.12.6

Package: fbi
Version: 2.07-6
Severity: normal
Tags: patch memleak



-- System Information:
Debian Release: 6.0.3
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- src/fbi-2.07/fb-gui.c       2006-08-14 20:38:05.000000000 +0100
+++ fbi-2.07/fb-gui.c   2012-01-15 22:41:12.000000000 +0000
@@ -10,6 +10,8 @@
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcfreetype.h>
 
+#include <freetype/freetype.h>
+
 #include "fbtools.h"
 #include "dither.h"
 #include "fb-gui.h"
@@ -627,10 +629,11 @@
     FcResult    result = 0;
     FT_Face     face = NULL;
     FcPattern   *pattern,*match;
-    char        *fontname,*h;
+    char        *fontname = NULL, *h = NULL;
     FcChar8     *filename;
     double      pixelsize;
     int         rc;
+    int         ok = 0;
 
     /* parse + match font name */
     pattern = FcNameParse(fcname);
@@ -638,8 +641,10 @@
     FcDefaultSubstitute(pattern);
     match = FcFontMatch (0, pattern, &result);
     FcPatternDestroy(pattern);
-    if (FcResultMatch != result)
-       return NULL;
+    if (FcResultMatch != result) {
+       ok = 0;
+       goto out;
+    }
     fontname = FcNameUnparse(match);
     h = strchr(fontname, ':');
     if (h)
@@ -649,24 +654,40 @@
     result = FcPatternGetFTFace(match, FC_FT_FACE, 0, &face);
     if (FcResultMatch == result) {
        fprintf(stderr,"using \"%s\", face=%p\n",fontname,face);
-       return face;
+       ok = 1;
+       goto out;
     }
 
     /* failing that use the filename */
     result = FcPatternGetString (match, FC_FILE, 0, &filename);
     if (FcResultMatch == result) {
-       result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixelsize);
+        result = FcPatternGetDouble(match, FC_PIXEL_SIZE, 0, &pixelsize);
+
        if (FcResultMatch != result)
            pixelsize = 16;
-       fprintf(stderr,"using \"%s\", pixelsize=%.2lf file=%s\n",
-               fontname,pixelsize,filename);
+
+       fprintf(stderr,"using \"%s\", pixelsize=%.2lf 
file=%s\n",fontname,pixelsize,filename);
+       ok = 1;
        rc = FT_New_Face (freetype, filename, 0, &face);
-       if (rc)
-           return NULL;
+
+       if (rc) {
+           ok = 0;
+           goto out;
+       }
+
        FT_Set_Pixel_Sizes(face, 0, (int)pixelsize);
-       return face;
     }
 
+out:
+    free(fontname);
+    FcPatternDestroy(match);
+
+    if (ok) {
+        /* we good */
+        return face;
+    }
+
+    FT_Done_FreeType(freetype);
     /* oops, didn't work */
     return NULL;
 }

Reply via email to