Blob Blame History Raw
From eee846339d2f76f568c62b3725bf75bcee728115 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Mon, 22 Sep 2014 11:27:22 +0200
Subject: [PATCH] test-util: make valgrind happy

Properly free all temporary resources to make valgrind not complain about
lost records.
---
 src/test/test-util.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/src/test/test-util.c b/src/test/test-util.c
index 80425ca61a..f8e42f3a55 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -843,11 +843,27 @@ static void test_is_valid_documentation_url(void) {
 }
 
 static void test_file_in_same_dir(void) {
-        assert_se(streq(file_in_same_dir("/", "a"), "/a"));
-        assert_se(streq(file_in_same_dir("/", "/a"), "/a"));
-        assert_se(streq(file_in_same_dir("", "a"), "a"));
-        assert_se(streq(file_in_same_dir("a/", "a"), "a/a"));
-        assert_se(streq(file_in_same_dir("bar/foo", "bar"), "bar/bar"));
+        char *t;
+
+        t = file_in_same_dir("/", "a");
+        assert_se(streq(t, "/a"));
+        free(t);
+
+        t = file_in_same_dir("/", "/a");
+        assert_se(streq(t, "/a"));
+        free(t);
+
+        t = file_in_same_dir("", "a");
+        assert_se(streq(t, "a"));
+        free(t);
+
+        t = file_in_same_dir("a/", "a");
+        assert_se(streq(t, "a/a"));
+        free(t);
+
+        t = file_in_same_dir("bar/foo", "bar");
+        assert_se(streq(t, "bar/bar"));
+        free(t);
 }
 
 static void test_endswith(void) {
@@ -1239,11 +1255,13 @@ static void test_unquote_many_words(void) {
         assert_se(unquote_many_words(&p, &a, NULL) == 1);
         assert_se(p == original+7);
         assert_se(streq_ptr(a, "foobar"));
+        free(a);
 
         p = original = "     foobar    ";
         assert_se(unquote_many_words(&p, &a, NULL) == 1);
         assert_se(p == original+15);
         assert_se(streq_ptr(a, "foobar"));
+        free(a);
 }
 
 int main(int argc, char *argv[]) {