From a2bb882da9830b39aefc0bccff6528e2756fca12 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Sun, 12 Oct 2014 21:15:12 +0100 Subject: [PATCH] Fix two possible crashes when changing desktop names 1. Fix a crash when the _NET_DESKTOP_NAMES atom is changed on the root window. Do not unset the gvalue from xfconf when this happens, unless it is not already a string type. In this case reinitialize it as a string. Test case: xprop -root -f '_NET_DESKTOP_NAMES' 8u -set '_NET_DESKTOP_NAMES' 'hello' 2. Fix a crash when non-string values are put into the xfconf property. Do not attempt to use these values as strings. Instead, create a default value. The result is copied back into xfconf when the atom is updated. Test case: xfconf-query -c xfwm4 -p /general/workspace_names -t int -s 1 -t int -s 2 Fixes https://bugzilla.xfce.org/show_bug.cgi?id=11229 --- xfsettingsd/workspaces.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xfsettingsd/workspaces.c b/xfsettingsd/workspaces.c index 3237504..d82b655 100644 --- a/xfsettingsd/workspaces.c +++ b/xfsettingsd/workspaces.c @@ -325,10 +325,21 @@ xfce_workspaces_helper_set_names_real (XfceWorkspacesHelper *helper) for (i = 0; i < names->len && i < n_workspaces; i++) { val = g_ptr_array_index (names, i); - name = g_value_get_string (val); + if(G_VALUE_HOLDS_STRING(val)) + { + name = g_value_get_string (val); - /* insert the name with nul */ - g_string_append_len (names_str, name, strlen (name) + 1); + /* insert the name with nul */ + g_string_append_len (names_str, name, strlen (name) + 1); + } + else + { + /* value in xfconf isn't a string, so make a default one */ + new_name = g_strdup_printf (_("Workspace %d"), i + 1); + /* insert the name with nul */ + g_string_append_len (names_str, new_name, strlen (new_name) + 1); + g_free(new_name); + } } /* update stamp so new names is not handled for the next second */ @@ -540,12 +551,16 @@ xfce_workspaces_helper_save_names (XfceWorkspacesHelper *helper) name_a = g_value_get_string (g_ptr_array_index (new_names, i)); val_b = g_ptr_array_index (xfconf_names, i); + if(!G_VALUE_HOLDS_STRING(val_b)) + { + g_value_unset(val_b); + g_value_init(val_b, G_TYPE_STRING); + } name_b = g_value_get_string (val_b); if (g_strcmp0 (name_a, name_b) != 0) { /* set the old xfconf name to the new name */ - g_value_unset (val_b); g_value_set_string (val_b, name_a); save_array = TRUE; -- 1.9.1