diff mbox

[03/28] tests: fix leaks in test-io-channel-command

Message ID 20170207135211.15870-4-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau Feb. 7, 2017, 1:51 p.m. UTC
No need for strdup, fix leaks when socat is missing.

Spotted by ASAN.

Cc: "Daniel P. Berrange" <berrange@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-io-channel-command.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Daniel P. Berrangé Feb. 7, 2017, 2:02 p.m. UTC | #1
On Tue, Feb 07, 2017 at 05:51:46PM +0400, Marc-André Lureau wrote:
> No need for strdup, fix leaks when socat is missing.
> 
> Spotted by ASAN.
> 
> Cc: "Daniel P. Berrange" <berrange@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  tests/test-io-channel-command.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)

ACK, I've added this to my queue, but if this merges via a
pull request for your entire series, that's fine too.

> 
> diff --git a/tests/test-io-channel-command.c b/tests/test-io-channel-command.c
> index 1d1f461bed..46ce1ff01c 100644
> --- a/tests/test-io-channel-command.c
> +++ b/tests/test-io-channel-command.c
> @@ -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);
>  }


Regards,
Daniel
Greg Kurz Feb. 7, 2017, 3:02 p.m. UTC | #2
On Tue,  7 Feb 2017 17:51:46 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> No need for strdup, fix leaks when socat is missing.
> 
> Spotted by ASAN.
> 
> Cc: "Daniel P. Berrange" <berrange@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---

Reviewed-by: Greg Kurz <groug@kaod.org>

>  tests/test-io-channel-command.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/test-io-channel-command.c b/tests/test-io-channel-command.c
> index 1d1f461bed..46ce1ff01c 100644
> --- a/tests/test-io-channel-command.c
> +++ b/tests/test-io-channel-command.c
> @@ -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);
>  }
>
diff mbox

Patch

diff --git a/tests/test-io-channel-command.c b/tests/test-io-channel-command.c
index 1d1f461bed..46ce1ff01c 100644
--- a/tests/test-io-channel-command.c
+++ b/tests/test-io-channel-command.c
@@ -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);
 }