fontconfig: Branch 'master'

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

 



 fc-match/fc-match.c  |    8 +++++++-
 src/fcxml.c          |    4 +++-
 test/test-bz106632.c |    8 ++++++++
 test/test-issue180.c |    4 +++-
 4 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit d55eaa6b3148691f32ec19c5c36dfc8818a6385f
Author: Ben Wagner <bungeman@xxxxxxxxxxxx>
Date:   Fri Dec 11 11:54:43 2020 -0500

    Fix leaks in fcxml.c, fc-match.c, and tests.
    
    Fix leaks reported by AddressSanitizer when running 'make check'.

diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c
index 4362ec1..f31047e 100644
--- a/fc-match/fc-match.c
+++ b/fc-match/fc-match.c
@@ -117,6 +117,7 @@ main (int argc, char **argv)
     int			brief = 0;
     int			sort = 0, all = 0;
     const FcChar8	*format = NULL;
+    const FcChar8	*format_optarg = NULL;
     int			i;
     FcObjectSet		*os = 0;
     FcFontSet		*fs;
@@ -146,7 +147,7 @@ main (int argc, char **argv)
 	    brief = 1;
 	    break;
 	case 'f':
-	    format = (FcChar8 *) strdup (optarg);
+	    format = format_optarg = (FcChar8 *) strdup (optarg);
 	    break;
 	case 'V':
 	    fprintf (stderr, "fontconfig version %d.%d.%d\n", 
@@ -269,5 +270,10 @@ main (int argc, char **argv)
 
     FcFini ();
 
+    if (format_optarg) {
+	free ((void*)format_optarg);
+	format_optarg = NULL;
+    }
+
     return 0;
 }
diff --git a/src/fcxml.c b/src/fcxml.c
index 3f22581..9efe157 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -2307,7 +2307,9 @@ FcParseCacheDir (FcConfigParse *parse)
     if (data[0] == 0)
     {
 	FcConfigMessage (parse, FcSevereWarning, "empty cache directory name ignored");
-	return;
+	FcStrFree (data);
+	data = prefix;
+	goto bail;
     }
     if (prefix)
     {
diff --git a/test/test-bz106632.c b/test/test-bz106632.c
index 0f37b9c..c610d73 100644
--- a/test/test-bz106632.c
+++ b/test/test-bz106632.c
@@ -221,6 +221,7 @@ main (void)
 	ret = 1;
 	goto bail;
     }
+    FcFontSetDestroy (fs);
     fprintf (stderr, "D: Removing %s\n", fontdir);
     snprintf (cmd, 512, "sleep 1; rm -f %s%s*; sleep 1", fontdir, FC_DIR_SEPARATOR_S);
     (void) system (cmd);
@@ -243,6 +244,8 @@ main (void)
 	ret = 3;
 	goto bail;
     }
+    FcConfigDestroy (config);
+
     config = FcConfigCreate ();
     if (!FcConfigParseAndLoadFromMemory (config, (const FcChar8 *) conf, FcTrue))
     {
@@ -266,6 +269,7 @@ main (void)
 	ret = 1;
 	goto bail;
     }
+    FcFontSetDestroy (fs);
     fprintf (stderr, "D: Copying %s to %s\n", FONTFILE, fontdir);
     snprintf (cmd, 512, "sleep 1; cp -a %s %s; sleep 1", FONTFILE, fontdir);
     (void) system (cmd);
@@ -288,6 +292,8 @@ main (void)
 	ret = 3;
 	goto bail;
     }
+    FcConfigDestroy (config);
+
     config = FcConfigCreate ();
     if (!FcConfigParseAndLoadFromMemory (config, (const FcChar8 *) conf, FcTrue))
     {
@@ -311,6 +317,8 @@ main (void)
 	ret = 1;
 	goto bail;
     }
+    FcFontSetDestroy (fs);
+    FcConfigDestroy (config);
 
 bail:
     fprintf (stderr, "Cleaning up\n");
diff --git a/test/test-issue180.c b/test/test-issue180.c
index 2832d3b..9d0795e 100644
--- a/test/test-issue180.c
+++ b/test/test-issue180.c
@@ -53,7 +53,9 @@ main (void)
 	fprintf (stderr, "There was one or more cachedirs\n");
 	return 1;
     }
+    FcStrListDone (l);
     FcConfigDestroy (cfg);
+
     cfg = FcConfigCreate ();
     if (!FcConfigParseAndLoadFromMemory (cfg, doc2, FcTrue))
     {
@@ -66,7 +68,7 @@ main (void)
 	fprintf (stderr, "There was one or more cachedirs (with prefix)\n");
 	return 1;
     }
-
+    FcStrListDone (l);
     FcConfigDestroy (cfg);
 
     return 0;
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://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