[virt-tools-list] [virt-viewer] ovirt: Fix OvirtApi memory handling

Jonathon Jongsma jjongsma at redhat.com
Tue Jul 28 14:40:55 UTC 2015


ACK


On Tue, 2015-07-28 at 14:14 +0200, Christophe Fergeau wrote:
> The oVirt integration code in remote-viewer assumes that
> the caller owns a reference on the OvirtApi instance returned
> by ovirt_proxy_fetch_api{,finish}.
> This is incorrect as these 2 API calls have always been documented as
> being (transfer none). This was working so far because libgovirt was
> leaking an OvirtApi reference. This bug is fixed upstream, so we now get
> a warning on remote-viewer exit about trying to unref an invalid object.
> 
> This commit fixes that by taking the ref we expect in OvirtForeignMenu,
> and by not releasing a ref we do not own in remote-viewer.c
> ---
>  src/ovirt-foreign-menu.c | 1 +
>  src/remote-viewer.c      | 2 --
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/ovirt-foreign-menu.c b/src/ovirt-foreign-menu.c
> index e4b3537..7c5a24a 100644
> --- a/src/ovirt-foreign-menu.c
> +++ b/src/ovirt-foreign-menu.c
> @@ -755,6 +755,7 @@ static void api_fetched_cb(GObject *source_object,
>          return;
>      }
>      g_return_if_fail(OVIRT_IS_API(menu->priv->api));
> +    g_object_ref(menu->priv->api);
>  
>      ovirt_foreign_menu_next_async_step(menu, STATE_API);
>  }
> diff --git a/src/remote-viewer.c b/src/remote-viewer.c
> index 8f30116..c3d2880 100644
> --- a/src/remote-viewer.c
> +++ b/src/remote-viewer.c
> @@ -1013,8 +1013,6 @@ error:
>          g_object_unref(display);
>      if (vm != NULL)
>          g_object_unref(vm);
> -    if (api != NULL)
> -        g_object_unref(api);
>      if (proxy != NULL)
>          g_object_unref(proxy);
>  





More information about the virt-tools-list mailing list