From f57f2e78ccd66ed1fc4dc83f74ee3bdc2ed510e7 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 7 Apr 2011 10:10:11 -0400 Subject: cancel-guard several callback functions --- src/application-service-appstore.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 25eba69..3e827d5 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -432,7 +432,6 @@ got_all_properties (GObject * source_object, GAsyncResult * res, g_return_if_fail(app != NULL); GError * error = NULL; - ApplicationServiceAppstorePrivate * priv = app->appstore->priv; GVariant * menu = NULL, * id = NULL, * category = NULL, * status = NULL, * icon_name = NULL, * aicon_name = NULL, * icon_desc = NULL, * aicon_desc = NULL, @@ -441,6 +440,11 @@ got_all_properties (GObject * source_object, GAsyncResult * res, GVariant * properties = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; // Must exit before accessing freed memory + } + if (app->props_cancel != NULL) { g_object_unref(app->props_cancel); app->props_cancel = NULL; @@ -454,6 +458,8 @@ got_all_properties (GObject * source_object, GAsyncResult * res, return; } + ApplicationServiceAppstorePrivate * priv = app->appstore->priv; + /* Grab all properties from variant */ GVariantIter * iter = NULL; const gchar * name = NULL; @@ -1043,6 +1049,11 @@ dbus_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; // Must exit before accessing freed memory + } + if (app->dbus_proxy_cancel != NULL) { g_object_unref(app->dbus_proxy_cancel); app->dbus_proxy_cancel = NULL; @@ -1437,6 +1448,12 @@ approver_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_return_if_fail(approver != NULL); GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { + g_error_free (error); + return; // Must exit before accessing freed memory + } + ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE (approver->appstore); if (approver->proxy_cancel != NULL) { -- cgit v1.2.3