[cairo] [PATCH 3/3] cairo-test-runner: don't leak argv

przanoni at gmail.com przanoni at gmail.com
Fri Sep 9 10:17:39 PDT 2011


From: Paulo Zanoni <paulo.r.zanoni at intel.com>

If CAIRO_TESTS is set, argv will be replaced by a xmaloc'ed variable. We
need to free it.

This can be easily detected by running:
CAIRO_TESTS=user-font make check-valgrind TARGETS=image

Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---

Makes it easier to debug leaks in the actual tests.

 test/cairo-test-runner.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 4afcafc..58e4045 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -715,6 +715,7 @@ main (int argc, char **argv)
     unsigned int n, m;
     char targets[4096];
     int len;
+    char *cairo_tests_env;
 
 #ifdef _MSC_VER
     /* We don't want an assert dialog, we want stderr */
@@ -752,7 +753,9 @@ main (int argc, char **argv)
     }
 
     _parse_cmdline (&runner, &argc, &argv);
-    append_argv (&argc, &argv, getenv ("CAIRO_TESTS"));
+
+    cairo_tests_env = getenv("CAIRO_TESTS");
+    append_argv (&argc, &argv, cairo_tests_env);
 
     if (runner.full_test) {
 	runner.num_device_offsets = 2;
@@ -1072,6 +1075,9 @@ main (int argc, char **argv)
 
     }
 
+    if (cairo_tests_env)
+	free(argv);
+
     if (runner.list_only) {
 	printf ("\n");
 	return CAIRO_TEST_SUCCESS;
-- 
1.7.4.1



More information about the cairo mailing list