qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] vhost-user-test: fix a memory leak


From: Marc-André Lureau
Subject: Re: [PATCH] vhost-user-test: fix a memory leak
Date: Wed, 11 Dec 2019 12:18:54 +0400

Hi

On Wed, Dec 11, 2019 at 11:57 AM Thomas Huth <address@hidden> wrote:
>
>  Hi!
>
> On 11/12/2019 01.55, address@hidden wrote:
> [...]
> > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> > index 91ea373..54be931 100644
> > --- a/tests/vhost-user-test.c
> > +++ b/tests/vhost-user-test.c
> > @@ -717,6 +717,8 @@ static void test_migrate(void *obj, void *arg, 
> > QGuestAllocator *alloc)
> >      guint64 size;
> >
> >      if (!wait_for_fds(s)) {
> > +        g_free(uri);
> > +        test_server_free(dest);
> >          return;
> >      }
>
> Well spotted. But I'd prefer to rather move the allocation of these
> resources after the if-statement instead of doing the allocation at the
> declaration of the variables already. Or maybe use a "goto out" and jump
> to the end of the function instead? ... whatever you prefer, but
> duplicating the "free" functions sounds like a cumbersome solution to me.

g_auto (preferably) should work as well.


-- 
Marc-André Lureau



reply via email to

[Prev in Thread] Current Thread [Next in Thread]