[Commit] Xft xftfreetype.c,1.35,1.36

Keith Packard commit@keithp.com
Fri, 16 May 2003 19:17:58 -0700


Committed by: keithp

Update of /local/src/CVS/Xft
In directory home.keithp.com:/tmp/cvs-serv29899

Modified Files:
	xftfreetype.c 
Log Message:
Free charset on font open failure.  Free charset and pattern on font close

Index: xftfreetype.c
===================================================================
RCS file: /local/src/CVS/Xft/xftfreetype.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- xftfreetype.c	2 May 2003 21:42:56 -0000	1.35
+++ xftfreetype.c	17 May 2003 02:17:55 -0000	1.36
@@ -683,7 +683,9 @@
      * off and compute it.  Yes, this is expensive, but it's
      * required to map Unicode to glyph indices.
      */
-    if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) != FcResultMatch)
+    if (FcPatternGetCharSet (pattern, FC_CHARSET, 0, &charset) == FcResultMatch)
+	charset = FcCharSetCopy (charset);
+    else
 	charset = FcFreeTypeCharSet (face, FcConfigGetBlanks (0));
     
     antialias = fi->antialias;
@@ -715,7 +717,7 @@
 	}
 	
 	if (!format)
-	    goto bail0;
+	    goto bail2;
     }
     else
 	format = 0;
@@ -744,7 +746,7 @@
     font = malloc (alloc_size);
     
     if (!font)
-	goto bail1;
+	goto bail2;
 
     XftMemAlloc (XFT_MEM_FONT, alloc_size);
 
@@ -866,6 +868,8 @@
 
     return &font->public;
     
+bail2:
+    FcCharSetDestroy (charset);
 bail1:
     _XftUnlockFile (fi->file);
 bail0:
@@ -921,6 +925,10 @@
 	    free (xftg);
 	}
     }
+    
+    /* Free the pattern and the charset */
+    FcPatternDestroy (font->public.pattern);
+    FcCharSetDestroy (font->public.charset);
     
     /* Finally, free the font structure */
     XftMemFree (XFT_MEM_FONT, sizeof (XftFontInt) +