From 04665545fccffb2557c563f1dc2a3b7bdaf5bfad 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 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 2. Fix a crash when the _NET_DESKTOP_NAMES atom is changed on the root window. Reinitialize as a string after the unset. xprop -root -f '_NET_DESKTOP_NAMES' 8u -set '_NET_DESKTOP_NAMES' 'hello' Fixes https://bugzilla.xfce.org/show_bug.cgi?id=11229 --- xfsettingsd/workspaces.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xfsettingsd/workspaces.c b/xfsettingsd/workspaces.c index 3237504..f1e6bc5 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 */ @@ -546,6 +557,7 @@ xfce_workspaces_helper_save_names (XfceWorkspacesHelper *helper) { /* set the old xfconf name to the new name */ g_value_unset (val_b); + g_value_init (val_b, G_TYPE_STRING); g_value_set_string (val_b, name_a); save_array = TRUE; -- 1.9.1