[libvirt] [PATCH 01/10] command: avoid leak on failure

Eric Blake eblake at redhat.com
Thu Jun 2 23:07:53 UTC 2011


Detected by Coverity.  While it is possible on OOM condition, as
well as with bad code that passes binary == NULL, it is unlikely
to be encountered in the wild.

* src/util/command.c (virCommandNewArgList): Don't leak memory.
---
 src/util/command.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/util/command.c b/src/util/command.c
index 288958e..a2f7ff6 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -142,7 +142,7 @@ virCommandNewArgList(const char *binary, ...)
     const char *arg;

     if (!cmd || cmd->has_error)
-        return NULL;
+        return cmd;

     va_start(list, binary);
     while ((arg = va_arg(list, const char *)) != NULL)
-- 
1.7.4.4




More information about the libvir-list mailing list