tests: fix leaks in test-io-channel-command
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 7 Feb 2017 13:51:46 +0000 (17:51 +0400)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 28 Feb 2017 10:36:32 +0000 (10:36 +0000)
No need for strdup, fix leaks when socat is missing.

Spotted by ASAN.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
tests/test-io-channel-command.c

index 1d1f461bed82fe3c7db6733a192b90e089287c17..46ce1ff01cd8ebcf84f796b6ad02ce9012424452 100644 (file)
@@ -29,8 +29,8 @@ static void test_io_channel_command_fifo(bool async)
 #define TEST_FIFO "tests/test-io-channel-command.fifo"
     QIOChannel *src, *dst;
     QIOChannelTest *test;
-    char *srcfifo = g_strdup_printf("PIPE:%s,wronly", TEST_FIFO);
-    char *dstfifo = g_strdup_printf("PIPE:%s,rdonly", TEST_FIFO);
+    const char *srcfifo = "PIPE:" TEST_FIFO ",wronly";
+    const char *dstfifo = "PIPE:" TEST_FIFO ",rdonly";
     const char *srcargv[] = {
         "/bin/socat", "-", srcfifo, NULL,
     };
@@ -59,8 +59,6 @@ static void test_io_channel_command_fifo(bool async)
     object_unref(OBJECT(src));
     object_unref(OBJECT(dst));
 
-    g_free(srcfifo);
-    g_free(dstfifo);
     unlink(TEST_FIFO);
 }