[libvirt] [PATCH] command: plug memory leak

* src/util/command.c (virCommandFree): Free data from virCommandSetInputBuffer. --- src/util/command.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/util/command.c b/src/util/command.c index 089e0bd..5e2b19a 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -1198,6 +1198,7 @@ virCommandFree(virCommandPtr cmd) } } + VIR_FREE(cmd->inbuf); VIR_FORCE_CLOSE(cmd->outfd); VIR_FORCE_CLOSE(cmd->errfd); -- 1.7.3.2

2010/12/10 Eric Blake <eblake@redhat.com>:
* src/util/command.c (virCommandFree): Free data from virCommandSetInputBuffer. --- src/util/command.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c index 089e0bd..5e2b19a 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -1198,6 +1198,7 @@ virCommandFree(virCommandPtr cmd) } }
+ VIR_FREE(cmd->inbuf); VIR_FORCE_CLOSE(cmd->outfd); VIR_FORCE_CLOSE(cmd->errfd);
At first I wanted to complain that virCommandSetInputBuffer isn't documented to take ownership of the inbuf, then I saw that it's strdup'ed :) ACK. Matthias

On 12/10/2010 10:26 AM, Matthias Bolte wrote:
2010/12/10 Eric Blake <eblake@redhat.com>:
* src/util/command.c (virCommandFree): Free data from virCommandSetInputBuffer.
At first I wanted to complain that virCommandSetInputBuffer isn't documented to take ownership of the inbuf, then I saw that it's strdup'ed :)
Yeah, virCommandSetInputBuffer takes char*, virCommandSetOutputBuffer takes char**; leaving subtly different lifetimes for the resulting strings.
ACK.
Thanks; pushed. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 12/10/2010 10:56 AM, Eric Blake wrote:
* src/util/command.c (virCommandFree): Free data from virCommandSetInputBuffer. --- src/util/command.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/util/command.c b/src/util/command.c index 089e0bd..5e2b19a 100644 --- a/src/util/command.c +++ b/src/util/command.c @@ -1198,6 +1198,7 @@ virCommandFree(virCommandPtr cmd) } }
+ VIR_FREE(cmd->inbuf); VIR_FORCE_CLOSE(cmd->outfd); VIR_FORCE_CLOSE(cmd->errfd);
ACK.
participants (3)
-
Eric Blake
-
Laine Stump
-
Matthias Bolte