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

Re: [libvirt] [PATCH 2/4] tests: Fix leaks in commandtest



On Mon, Dec 06, 2010 at 01:03:25PM +0100, Jiri Denemark wrote:
> ---
>  tests/commandtest.c |  213 +++++++++++++++++++++++++++++++++-----------------
>  1 files changed, 140 insertions(+), 73 deletions(-)
> 
> diff --git a/tests/commandtest.c b/tests/commandtest.c
> index 9ccbcef..48c6335 100644
> --- a/tests/commandtest.c
> +++ b/tests/commandtest.c
> @@ -107,7 +107,7 @@ static int test0(const void *unused ATTRIBUTE_UNUSED)
>  
>      free(virtTestLogContentAndReset());
>      cmd = virCommandNew(abs_builddir "/commandhelper-doesnotexist");
> -    if (virCommandRun(cmd, NULL) == 0)
> +    if (!cmd || virCommandRun(cmd, NULL) == 0)

The API explicitly does *not* require you to check
!cmd after virCommandNew. virCommandRun() and other
APis will check that for you and return ENOMEM.

Daniel


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