background: Fix crash when adding the second color

https://bugzilla.gnome.org/show_bug.cgi?id=689351
This commit is contained in:
Debarshi Ray 2014-11-04 18:05:05 +01:00
parent d227fa4a88
commit 041671e485

View file

@ -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);