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

Christophe Fergeau cfergeau at redhat.com
Tue May 10 08:01:12 UTC 2016


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 027cd68..88c6be5 100644
--- a/src/ovirt-foreign-menu.c
+++ b/src/ovirt-foreign-menu.c
@@ -759,6 +759,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 ac80dee..f76350d 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -997,8 +997,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);
 
-- 
2.7.4




More information about the virt-tools-list mailing list