diff options
author | Eduardo Lima (Etrunko) <etrunko@redhat.com> | 2017-02-02 15:11:42 -0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2017-02-06 16:58:56 +0100 |
commit | 25beefa304af1fa5ce529401ccb19aac252dd185 (patch) | |
tree | a63ae6c63ee1fee60d7e5e76830b6e25deab5ec6 | |
parent | 82cfd86b978f5e94fae1b028c36bc1ac58cc1374 (diff) |
proxy: Hold reference to cancellable object
Being an asynchronous operation, there is no guarantee that the object
is valid by the time of the cleanup, so we hold a reference to it to
ensure it.
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
-rw-r--r-- | govirt/ovirt-proxy.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c index 10cc25f..70c08ac 100644 --- a/govirt/ovirt-proxy.c +++ b/govirt/ovirt-proxy.c @@ -218,6 +218,7 @@ static void ovirt_proxy_call_async_data_free(OvirtProxyCallAsyncData *data) if ((data->cancellable != NULL) && (data->cancellable_cb_id != 0)) { g_cancellable_disconnect(data->cancellable, data->cancellable_cb_id); } + g_clear_object(&data->cancellable); g_slice_free(OvirtProxyCallAsyncData, data); } @@ -282,7 +283,7 @@ void ovirt_rest_call_async(OvirtRestCall *call, data->call_user_data = user_data; data->destroy_call_data = destroy_func; if (cancellable != NULL) { - data->cancellable = cancellable; + data->cancellable = g_object_ref(cancellable); data->cancellable_cb_id = g_cancellable_connect(cancellable, G_CALLBACK (call_async_cancelled_cb), call, NULL); |