From 0b93c0f2ab1cdba1775516910d1b4971c213dfcc Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Tue, 28 Jul 2015 14:08:39 +0200
Subject: [PATCH] ovirt: Fix OvirtApi memory handling
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
(cherry picked from commit 9aa7aec9a934ee9d3d505217aa64383bef3d2f05)
---
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 f9447c8..b170054 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 ab44f81..2d40640 100644
--- a/src/remote-viewer.c
+++ b/src/remote-viewer.c
@@ -979,8 +979,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);