Re: Patch: fix memory leak (spotted by Coverity)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le mardi 11 avril 2006 à 17:39 +0200, Frederic Crozat a écrit :
> The following patch fixes a memory leak in FcConfigBuildFonts (Coverity
> defect #985) in error case.

Better patch attached, it fixes another memory leak in FcConfigAddBlank
too (Coverity defect #776).

-- 
Frederic Crozat <fcrozat@xxxxxxxxxxxx>
Mandriva
Index: ChangeLog
===================================================================
RCS file: /cvs/fontconfig/fontconfig/ChangeLog,v
retrieving revision 1.109.2.193
diff -u -p -r1.109.2.193 ChangeLog
--- ChangeLog	11 Apr 2006 14:20:59 -0000	1.109.2.193
+++ ChangeLog	11 Apr 2006 16:12:56 -0000
@@ -1,3 +1,8 @@
+2006-04-11  Frederic Crozat  <fcrozat@xxxxxxxxxxxx>
+
+	* src/fccfg.c: (FcConfigAddBlank), (FcConfigBuildFonts):
+	Fix memory leaks in error case (Coverity defect #776, #985).
+
 2006-04-11  Patrick Lam  <plam@xxxxxxx>
 	* src/fccharset.c (FcCharSetPutLeaf):
 
Index: src/fccfg.c
===================================================================
RCS file: /cvs/fontconfig/fontconfig/src/fccfg.c,v
retrieving revision 1.49.2.26
diff -u -p -r1.49.2.26 fccfg.c
--- src/fccfg.c	10 Apr 2006 19:33:03 -0000	1.49.2.26
+++ src/fccfg.c	11 Apr 2006 16:12:57 -0000
@@ -283,7 +283,7 @@
     {
 	list = FcConfigGetFontDirs (config);
 	if (!list)
-	    goto bail2;
+	    goto bail3;
 	
 	while ((dir = FcStrListNext (list)))
 	{
@@ -334,9 +334,10 @@
     FcConfigSetFonts (config, fonts, FcSetSystem);
     
     return FcTrue;
+bail3:
+    FcStrSetDestroy (oldDirs);
 bail2:
     FcGlobalCacheDestroy (cache);
-    FcStrSetDestroy (oldDirs);
 bail1:
     FcFontSetDestroy (fonts);
 bail0:
@@ -605,17 +606,21 @@
 FcConfigAddBlank (FcConfig	*config,
 		  FcChar32    	blank)
 {
-    FcBlanks	*b;
+    FcBlanks	*b, *freeme = 0;
     
     b = config->blanks;
     if (!b)
     {
-	b = FcBlanksCreate ();
+	freeme = b = FcBlanksCreate ();
 	if (!b)
 	    return FcFalse;
     }
     if (!FcBlanksAdd (b, blank))
+    {
+	if (freeme)
+            FcBlanksDestroy (freeme);
 	return FcFalse;
+    }
     config->blanks = b;
     return FcTrue;
 }
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux