[gnome-shell] extensions-tool: Fix removing from settings list



commit bb48205aae34e6bf0ce1810ab784bf36f00bc4d2
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Nov 25 01:49:04 2019 +0100

    extensions-tool: Fix removing from settings list
    
    When removing a string from a settings list, we iterate over all
    existing entries and copy all strings except the one that's being
    removed to a new list, which is then written to GSettings.
    
    However we currently always increment the index, so we end up with
    a NULL entry in place of the removed entry, which is then interpreted
    as the end of the list. In other words, we also remove all entries
    that follow the removed string.
    
    Fix this by looping over the list entries instead of the index, and
    only increment the index for entries we copy.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/1946

 src/extensions-tool/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/extensions-tool/main.c b/src/extensions-tool/main.c
index 7cc83de952..e9a457018e 100644
--- a/src/extensions-tool/main.c
+++ b/src/extensions-tool/main.c
@@ -142,9 +142,10 @@ settings_list_remove (GSettings  *settings,
 
   n_values = g_strv_length (list);
   new_value = g_new0 (char *, n_values);
-  for (i = 0, s = (const char **)list; i < n_values; i++, s++)
+  i = 0;
+  for (s = (const char **)list; *s != NULL; s++)
     if (!g_str_equal (*s, value))
-      new_value[i] = g_strdup (*s);
+      new_value[i++] = g_strdup (*s);
 
   g_settings_set_strv (settings, key, (const char **)new_value);
   g_settings_sync ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]