diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-11-08 11:01:58 -0600 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-11-08 11:01:58 -0600 |
commit | b72aaf89bff172d00141bff2da405934ab370743 (patch) | |
tree | 7469612769bc5dfb5d608fa0a694303a767a8355 /src | |
parent | 4af45b95b38c9fee98ddcfdf616fb8cda3e31823 (diff) | |
download | ayatana-indicator-session-b72aaf89bff172d00141bff2da405934ab370743.tar.gz ayatana-indicator-session-b72aaf89bff172d00141bff2da405934ab370743.tar.bz2 ayatana-indicator-session-b72aaf89bff172d00141bff2da405934ab370743.zip |
don't leak the output from g_icon_serialize
Diffstat (limited to 'src')
-rw-r--r-- | src/service.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/service.c b/src/service.c index efcb04f..9188317 100644 --- a/src/service.c +++ b/src/service.c @@ -149,6 +149,7 @@ action_state_for_header (IndicatorSessionService * self) const priv_t * const p = self->priv; gboolean need_attn; GIcon * icon; + GVariant * serialized_icon; gboolean show_name; const gchar * real_name; const gchar * label; @@ -196,7 +197,13 @@ action_state_for_header (IndicatorSessionService * self) /* build the state */ g_variant_builder_init (&b, G_VARIANT_TYPE("a{sv}")); g_variant_builder_add (&b, "{sv}", "accessible-desc", g_variant_new_string (a11y)); - g_variant_builder_add (&b, "{sv}", "icon", g_icon_serialize (icon)); + + if ((serialized_icon = g_icon_serialize (icon))) + { + g_variant_builder_add (&b, "{sv}", "icon", serialized_icon); + g_variant_unref (serialized_icon); + } + if (label && *label) g_variant_builder_add (&b, "{sv}", "label", g_variant_new_string (label)); g_variant_builder_add (&b, "{sv}", "visible", g_variant_new_boolean (TRUE)); @@ -517,9 +524,18 @@ create_switch_section (IndicatorSessionService * self) if (u->icon_file != NULL) { - GFile * file = g_file_new_for_path (u->icon_file); - GIcon * icon = g_file_icon_new (file); - g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_ICON, g_icon_serialize (icon)); + GFile * file; + GIcon * icon; + GVariant * serialized_icon; + + file = g_file_new_for_path (u->icon_file); + icon = g_file_icon_new (file); + if ((serialized_icon = g_icon_serialize (icon))) + { + g_menu_item_set_attribute_value (item, G_MENU_ATTRIBUTE_ICON, serialized_icon); + g_variant_unref (serialized_icon); + } + g_clear_object (&icon); g_clear_object (&file); } |