Re: [PATCH 01/16] Free memory on exit, fixes a problem found by coverity.

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

 



On Tue, Apr 02, 2013 at 06:11:17PM -0400, Dan Walsh wrote:
> Signed-off-by: Dan Walsh <dwalsh@xxxxxxxxxx>
> ---
>  bin/virt-sandbox-service-util.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/bin/virt-sandbox-service-util.c b/bin/virt-sandbox-service-util.c
> index 4d164d8..430518f 100644
> --- a/bin/virt-sandbox-service-util.c
> +++ b/bin/virt-sandbox-service-util.c
> @@ -194,8 +194,8 @@ 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;
>  
>      if (set_process_label(pid) < 0)
>          goto cleanup;
> @@ -227,6 +227,10 @@ static int container_execute( GVirSandboxContext *ctx, const gchar *command, pid
>      }
>  
>  cleanup:
> +    if (argc > -1)
> +            free(argv[0]);

This is still leaking all except for the first argv element. You need
to free all elements.

> +    free(argv);
> +

Regards,
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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]