- for (it = g_slist_nth(config_desktops_names, i); it;
- it = g_slist_next(it), ++i)
- {
- screen_desktop_names = g_renew(gchar*, screen_desktop_names, i + 2);
- screen_desktop_names[i] = g_strdup(it->data);
- screen_desktop_names[i+1] = NULL;
+ numnames = g_slist_length(config_desktops_names);
+ if (numnames > i) {
+ GSList *it;
+
+ screen_desktop_names = g_renew(gchar*,screen_desktop_names,numnames+1);
+ screen_desktop_names[numnames] = NULL;
+
+ for (it = g_slist_nth(config_desktops_names, i); it;
+ it = g_slist_next(it), ++i)
+ {
+ screen_desktop_names[i] = g_strdup(it->data);
+ }