[gnome-control-center] background: Fix crash when adding the second color



commit 041671e4854374ebfdeaa7aed56117e34e8590b5
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Nov 4 18:05:05 2014 +0100

    background: Fix crash when adding the second color
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689351

 panels/background/bg-colors-source.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/panels/background/bg-colors-source.c b/panels/background/bg-colors-source.c
index 09e484a..afe5868 100644
--- a/panels/background/bg-colors-source.c
+++ b/panels/background/bg-colors-source.c
@@ -222,8 +222,21 @@ bg_colors_source_add (BgColorsSource       *self,
     }
   else
     {
-      colors[len] = c;
+      char **new_colors;
+      guint i;
+
+      new_colors = g_new0 (char *, len + 2);
+      for (i = 0; colors[i] != NULL; i++)
+        {
+          new_colors[i] = colors[i];
+          colors[i] = NULL;
+        }
+
+      new_colors[len] = c;
       len++;
+
+      g_strfreev (colors);
+      colors = new_colors;
     }
 
   g_key_file_set_string_list (keyfile, "Colors", "custom-colors", (const gchar * const*) colors, len);


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