fontconfig: Branch 'master' - 2 commits

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

 



 fc-cat/fc-cat.c |    9 +++------
 src/fccfg.c     |    5 +++++
 src/fcinit.c    |    9 ++++++++-
 3 files changed, 16 insertions(+), 7 deletions(-)

New commits:
commit eb2689c67ba2da969d33be43a05af1e8975e9837
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Tue Aug 12 18:53:04 2014 +0900

    Fix the memory leak in fc-cat

diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
index 3a303c2..f0131b6 100644
--- a/fc-cat/fc-cat.c
+++ b/fc-cat/fc-cat.c
@@ -316,12 +316,6 @@ main (int argc, char **argv)
 		return 1;
 	    }
 	}
-	arglist = FcStrListCreate (args);
-	if (!arglist)
-	{
-	    fprintf (stderr, "%s: malloc failure\n", argv[0]);
-	    return 1;
-	}
     }
     else
     {
@@ -341,6 +335,7 @@ main (int argc, char **argv)
 	fprintf (stderr, "%s: malloc failure\n", argv[0]);
 	return 1;
     }
+    FcStrSetDestroy (args);
 
     while ((arg = FcStrListNext (arglist)))
     {
@@ -385,6 +380,7 @@ main (int argc, char **argv)
 	if (cache_file)
 	    FcStrFree (cache_file);
     }
+    FcStrListDone (arglist);
 
     FcFini ();
     return 0;
commit 23e88d8c6a5d3d0a9526a3f3217bd33a7607cbab
Author: Akira TAGOH <akira@xxxxxxxxx>
Date:   Tue Aug 12 18:48:00 2014 +0900

    Increase the refcount in FcConfigSetCurrent()
    
    https://bugs.freedesktop.org/show_bug.cgi?id=82432

diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
index 9a2abb3..3a303c2 100644
--- a/fc-cat/fc-cat.c
+++ b/fc-cat/fc-cat.c
@@ -298,6 +298,7 @@ main (int argc, char **argv)
 	return 1;
     }
     FcConfigSetCurrent (config);
+    FcConfigDestroy (config);
     
     args = FcStrSetCreate ();
     if (!args)
diff --git a/src/fccfg.c b/src/fccfg.c
index f8ee8d2..55cb297 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -434,6 +434,7 @@ retry:
     if (!fc_atomic_ptr_cmpexch (&_fcConfig, cfg, config))
 	goto retry;
 
+    FcConfigReference (config);
     if (cfg)
 	FcConfigDestroy (cfg);
 
@@ -2405,6 +2406,10 @@ FcConfigSetSysRoot (FcConfig      *config,
     {
 	config = FcInitLoadOwnConfigAndFonts (config);
 	FcConfigSetCurrent (config);
+	/* FcConfigSetCurrent() increases the refcount.
+	 * decrease it here to avoid the memory leak.
+	 */
+	FcConfigDestroy (config);
     }
 }
 
diff --git a/src/fcinit.c b/src/fcinit.c
index 1e23c1f..db62c21 100644
--- a/src/fcinit.c
+++ b/src/fcinit.c
@@ -189,11 +189,18 @@ FcBool
 FcInitReinitialize (void)
 {
     FcConfig	*config;
+    FcBool	ret;
 
     config = FcInitLoadConfigAndFonts ();
     if (!config)
 	return FcFalse;
-    return FcConfigSetCurrent (config);
+    ret = FcConfigSetCurrent (config);
+    /* FcConfigSetCurrent() increases the refcount.
+     * decrease it here to avoid the memory leak.
+     */
+    FcConfigDestroy (config);
+
+    return ret;
 }
 
 FcBool
_______________________________________________
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