chiark / gitweb /
tests: fix minor memory leak
authorLennart Poettering <lennart@poettering.net>
Wed, 19 Nov 2014 15:43:41 +0000 (16:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 19 Nov 2014 23:01:05 +0000 (00:01 +0100)
src/test/test-unit-name.c
src/test/test-util.c

index 256e820..ab6c488 100644 (file)
@@ -135,7 +135,7 @@ static int test_unit_printf(void) {
 #define expect(unit, pattern, expected)                                 \
         {                                                               \
                 char *e;                                                \
-                _cleanup_free_ char *t;                                 \
+                _cleanup_free_ char *t = NULL;                          \
                 assert_se(unit_full_printf(unit, pattern, &t) >= 0);    \
                 printf("result: %s\nexpect: %s\n", t, expected);        \
                 if ((e = endswith(expected, "*")))                      \
index 01b0192..01e10c9 100644 (file)
@@ -1217,6 +1217,7 @@ static void test_unquote_first_word(void) {
         p = original = "\'fooo";
         assert_se(unquote_first_word(&p, &t, true) > 0);
         assert_se(streq(t, "fooo"));
+        free(t);
         assert_se(p == original + 5);
 
         p = original = "yay\'foo\'bar";