From 79e3bfeacfc134a7a96b2a47b2ca3f285535262c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 20:55:43 -0600 Subject: Fixing variant usage --- src/application-service-appstore.c | 48 ++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 0548ced..587557e 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -268,8 +268,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data); GVariant * retval = NULL; Application *app = NULL; - const gchar *dbusaddress; - const gchar *dbusmenuobject; + gchar *dbusaddress; + gchar *dbusmenuobject; if (g_strcmp0(method, "GetApplications") == 0) { retval = get_applications(service); @@ -278,7 +278,7 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, gint delta; guint direction; - g_variant_get (params, "(&s&siu)", &dbusaddress, &dbusmenuobject, + g_variant_get (params, "(ssiu)", &dbusaddress, &dbusmenuobject, &delta, &direction); switch (direction) { @@ -304,7 +304,7 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, } else if (g_strcmp0(method, "ApplicationSecondaryActivateEvent") == 0) { guint time; - g_variant_get (params, "(&s&su)", &dbusaddress, &dbusmenuobject, &time); + g_variant_get (params, "(ssu)", &dbusaddress, &dbusmenuobject, &time); app = find_application_by_menu(service, dbusaddress, dbusmenuobject); if (app != NULL && app->dbus_proxy != NULL) { @@ -316,6 +316,9 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, g_warning("Calling method '%s' on the indicator service and it's unknown", method); } + g_free(dbusaddress); + g_free(dbusmenuobject); + g_dbus_method_invocation_return_value(invocation, retval); return; } @@ -1096,11 +1099,13 @@ name_changed (GDBusConnection * connection, const gchar * sender_name, { Application * app = (Application *)user_data; - const gchar * new_name; - g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_name); + gchar * new_name; + g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) application_died(app); + + g_free(new_name); } /* Callback from trying to create the proxy for the app. */ @@ -1223,19 +1228,23 @@ app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name get_all_properties(app); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_STATUS) == 0) { - const gchar * status; - g_variant_get(parameters, "(&s)", &status); + gchar * status; + g_variant_get(parameters, "(s)", &status); new_status(app, status); + g_free(status); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH) == 0) { - const gchar * icon_theme_path; - g_variant_get(parameters, "(&s)", &icon_theme_path); + gchar * icon_theme_path; + g_variant_get(parameters, "(s)", &icon_theme_path); new_icon_theme_path(app, icon_theme_path); + g_free(icon_theme_path); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_LABEL) == 0) { - const gchar * label, * guide; - g_variant_get(parameters, "(&s&s)", &label, &guide); + gchar * label, * guide; + g_variant_get(parameters, "(ss)", &label, &guide); new_label(app, label, guide); + g_free(label); + g_free(guide); } return; @@ -1560,13 +1569,16 @@ approver_name_changed (GDBusConnection * connection, const gchar * sender_name, Approver * approver = (Approver *)user_data; ApplicationServiceAppstore * appstore = approver->appstore; - const gchar * new_name; - g_variant_get(parameters, "(&s&s&s)", NULL, NULL, &new_name); + gchar * new_name; + g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) { appstore->priv->approvers = g_list_remove(appstore->priv->approvers, approver); approver_free(approver, appstore); } + + g_free(new_name); + return; } /* Callback from trying to create the proxy for the approver. */ @@ -1632,10 +1644,12 @@ approver_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal if (g_strcmp0(signal_name, "ReviseJudgement") == 0) { gboolean approved; - const gchar * address; - const gchar * path; - g_variant_get(parameters, "(b&s&o)", &approved, &address, &path); + gchar * address; + gchar * path; + g_variant_get(parameters, "(bso)", &approved, &address, &path); approver_revise_judgement(approver, approved, address, path); + g_free(address); + g_free(path); } return; -- cgit v1.2.3 From 18b22173e0e0f07cdfe75bb3bd15ae7ad80e4e97 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:01:20 -0600 Subject: Ensuring that the values are initialized to NULL before using that later. --- src/application-service-appstore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 587557e..8b06eec 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -268,8 +268,8 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, ApplicationServiceAppstore * service = APPLICATION_SERVICE_APPSTORE(user_data); GVariant * retval = NULL; Application *app = NULL; - gchar *dbusaddress; - gchar *dbusmenuobject; + gchar *dbusaddress = NULL; + gchar *dbusmenuobject = NULL; if (g_strcmp0(method, "GetApplications") == 0) { retval = get_applications(service); -- cgit v1.2.3 From ee1ac0d31371b8c472c44715eb7dce36b2793cc5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:10:50 -0600 Subject: Make sure to initialize values before free'ing them --- src/application-service-appstore.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 8b06eec..c0ec327 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1228,19 +1228,19 @@ app_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name get_all_properties(app); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_STATUS) == 0) { - gchar * status; + gchar * status = NULL; g_variant_get(parameters, "(s)", &status); new_status(app, status); g_free(status); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_ICON_THEME_PATH) == 0) { - gchar * icon_theme_path; + gchar * icon_theme_path = NULL; g_variant_get(parameters, "(s)", &icon_theme_path); new_icon_theme_path(app, icon_theme_path); g_free(icon_theme_path); } else if (g_strcmp0(signal_name, NOTIFICATION_ITEM_SIG_NEW_LABEL) == 0) { - gchar * label, * guide; + gchar * label = NULL, * guide = NULL; g_variant_get(parameters, "(ss)", &label, &guide); new_label(app, label, guide); g_free(label); @@ -1569,7 +1569,7 @@ approver_name_changed (GDBusConnection * connection, const gchar * sender_name, Approver * approver = (Approver *)user_data; ApplicationServiceAppstore * appstore = approver->appstore; - gchar * new_name; + gchar * new_name = NULL; g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) { @@ -1643,9 +1643,9 @@ approver_receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal Approver * approver = (Approver *)user_data; if (g_strcmp0(signal_name, "ReviseJudgement") == 0) { - gboolean approved; - gchar * address; - gchar * path; + gboolean approved = FALSE; + gchar * address = NULL; + gchar * path = NULL; g_variant_get(parameters, "(bso)", &approved, &address, &path); approver_revise_judgement(approver, approved, address, path); g_free(address); -- cgit v1.2.3 From a85b08ad050bf8e1acd39f58c5d3984eefd57e6a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 3 Feb 2012 22:13:38 -0600 Subject: Oops, forgot one --- src/application-service-appstore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application-service-appstore.c') diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index c0ec327..da5b859 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -1099,7 +1099,7 @@ name_changed (GDBusConnection * connection, const gchar * sender_name, { Application * app = (Application *)user_data; - gchar * new_name; + gchar * new_name = NULL; g_variant_get(parameters, "(sss)", NULL, NULL, &new_name); if (new_name == NULL || new_name[0] == 0) -- cgit v1.2.3