[Libguestfs] [PATCH] launch: libvirt: do not leak the backend string on error

Richard W.M. Jones rjones at redhat.com
Wed Jan 21 14:01:25 UTC 2015


On Tue, Jan 20, 2015 at 04:28:41PM +0100, Pino Toscano wrote:
> Make sure to free the backend string after using it.
> ---
>  src/launch-libvirt.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
> index 899742f..6f95e98 100644
> --- a/src/launch-libvirt.c
> +++ b/src/launch-libvirt.c
> @@ -719,6 +719,8 @@ parse_capabilities (guestfs_h *g, const char *capabilities_xml,
>     * appliance VM.
>     */
>    if (!seen_qemu && !seen_kvm) {
> +    CLEANUP_FREE char *backend = guestfs_get_backend (g);
> +
>      error (g,
>             _("libvirt hypervisor doesn't support qemu or KVM,\n"
>               "so we cannot create the libguestfs appliance.\n"
> @@ -730,7 +732,7 @@ parse_capabilities (guestfs_h *g, const char *capabilities_xml,
>               "Or: if you want to have libguestfs run qemu directly, try:\n"
>               "  export LIBGUESTFS_BACKEND=direct\n"
>               "For further help, read the guestfs(3) man page and libguestfs FAQ."),
> -           guestfs_get_backend (g));
> +           backend);
>      return -1;
>    }
>  
> -- 
> 1.9.3

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org




More information about the Libguestfs mailing list