[libvirt] [PATCH 2/4] tests: Fix leaks in commandtest
Daniel P. Berrange
berrange at redhat.com
Mon Dec 6 12:26:51 UTC 2010
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
More information about the libvir-list
mailing list