Re: [PATCH 12/21] virt-admin: Don't leak uri all over the place

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

 



On Thu, Mar 10, 2016 at 05:54:01AM +0100, Martin Kletzander wrote:
> virAdmConnectGetURI() returns string that needs to be free()'d but we
> haven't done that very much.
> 
> Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
> ---
>  tools/virt-admin.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> index c47053639dd0..bc9ae9366280 100644
> --- a/tools/virt-admin.c
> +++ b/tools/virt-admin.c
> @@ -69,9 +69,6 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn ATTRIBUTE_UNUSED,
>      virErrorPtr error;
>      char *uri = NULL;
> 
> -    if (reason == VIR_CONNECT_CLOSE_REASON_CLIENT)
> -        return;
> -

What is the reason for this change?

>      error = virSaveLastError();
>      uri = virAdmConnectGetURI(conn);
> 
> @@ -98,6 +95,8 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn ATTRIBUTE_UNUSED,
>          virSetError(error);
>          virFreeError(error);
>      }
> +
> +    VIR_FREE(uri);
>  }
> 
>  static int

This is already freed as of commit 34111a60

> @@ -323,7 +322,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
>      int nsrvs = 0;
>      size_t i;
>      bool ret = false;
> -    const char *uri = NULL;
> +    char *uri = NULL;
>      virAdmServerPtr *srvs = NULL;
>      vshAdmControlPtr priv = ctl->privData;
> 
> @@ -347,6 +346,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
>              virAdmServerFree(srvs[i]);
>          VIR_FREE(srvs);
>      }
> +    VIR_FREE(uri);
> 
>      return ret;
>  }

ACK to these two hunks.
Maybe s/all over the place/in cmdSrvList/ in the commit message.

Jan

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

--
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]