[libvirt] [sandbox PATCH 01/15] virt-sandbox-service-util needs to free allocated memory.
Daniel P. Berrange
berrange at redhat.com
Fri Apr 5 11:03:32 UTC 2013
On Wed, Apr 03, 2013 at 07:17:19PM -0400, Dan Walsh wrote:
> Coverity found that we could be leaking memory with virt-sandbox-service-util -e
> ---
> bin/virt-sandbox-service-util.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/bin/virt-sandbox-service-util.c b/bin/virt-sandbox-service-util.c
> index 4d164d8..a292fcd 100644
> --- a/bin/virt-sandbox-service-util.c
> +++ b/bin/virt-sandbox-service-util.c
> @@ -194,8 +194,9 @@ static int set_process_label(pid_t pid) {
> static int container_execute( GVirSandboxContext *ctx, const gchar *command, pid_t pid ) {
>
> int ret = EXIT_FAILURE;
> - char **argv;
> - int argc;
> + char **argv = NULL;
> + int argc=-1;
> + int i;
>
> if (set_process_label(pid) < 0)
> goto cleanup;
> @@ -227,6 +228,10 @@ static int container_execute( GVirSandboxContext *ctx, const gchar *command, pid
> }
>
> cleanup:
> + for (i = argc; i >= 0; i--)
Can you use the more normal (i = 0 ; i < argc ; i++)
> + free(argv[i]);
Identation is off here
> + free(argv);
> +
> return ret;
> }
ACK if those two things are fixed before pushing.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list