summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2021-01-08 14:38:27 +0100
committerraveit65 <[email protected]>2021-01-28 21:24:44 +0100
commit71a3e400589bc037ecb043ed27ac255166722a1c (patch)
treef4a46d932500fa9644a3fb97d9505bbafab53792
parent35ab6f3742c23ee7a1e8f347cd4bc2ca648ddcb3 (diff)
downloadmate-applets-71a3e400589bc037ecb043ed27ac255166722a1c.tar.bz2
mate-applets-71a3e400589bc037ecb043ed27ac255166722a1c.tar.xz
charpick: Fix memory leak
-rw-r--r--charpick/charpick.c28
-rw-r--r--charpick/properties.c19
2 files changed, 20 insertions, 27 deletions
diff --git a/charpick/charpick.c b/charpick/charpick.c
index 6991b34f..6f03e6b6 100644
--- a/charpick/charpick.c
+++ b/charpick/charpick.c
@@ -280,7 +280,9 @@ menuitem_activated (GtkMenuItem *menuitem,
if (g_ascii_strcasecmp (curr_data->charlist, string) == 0)
return;
- curr_data->charlist = string;
+ g_free (curr_data->charlist);
+ curr_data->charlist = g_strdup (string);
+
build_table (curr_data);
if (g_settings_is_writable (curr_data->settings, "current-list"))
g_settings_set_string (curr_data->settings,
@@ -653,6 +655,7 @@ applet_destroy (GtkWidget *widget,
gtk_widget_destroy (curr_data->box);
if (curr_data->menu)
gtk_widget_destroy (curr_data->menu);
+ g_free (curr_data->charlist);
g_free (curr_data);
}
@@ -727,7 +730,6 @@ charpicker_applet_fill (MatePanelApplet *applet)
MatePanelAppletOrient orientation;
charpick_data *curr_data;
GdkAtom utf8_atom;
- GList *list;
gchar *string;
GtkActionGroup *action_group;
@@ -748,24 +750,12 @@ charpicker_applet_fill (MatePanelApplet *applet)
get_chartable (curr_data);
string = g_settings_get_string (curr_data->settings, "current-list");
- if (string) {
- list = curr_data->chartable;
- while (list) {
- if (g_ascii_strcasecmp (list->data, string) == 0)
- curr_data->charlist = list->data;
- list = g_list_next (list);
- }
- /* FIXME: yeah leak, but this code is full of leaks and evil
- point shuffling. This should really be rewritten
- -George */
- if (curr_data->charlist == NULL)
- curr_data->charlist = string;
- else
- g_free (string);
- }
- else {
- curr_data->charlist = curr_data->chartable->data;
+ if (string && *string != '\0') {
+ curr_data->charlist = g_strdup (string);
+ } else {
+ curr_data->charlist = g_strdup (curr_data->chartable->data);
}
+ g_free (string);
curr_data->panel_size = mate_panel_applet_get_size (applet);
diff --git a/charpick/properties.c b/charpick/properties.c
index f0693115..c837eac8 100644
--- a/charpick/properties.c
+++ b/charpick/properties.c
@@ -138,12 +138,13 @@ add_palette_cb (GtkDialog *dialog,
if (curr_data->chartable == NULL) {
curr_data->chartable = list;
- curr_data->charlist = curr_data->chartable->data;
+ g_free (curr_data->charlist);
+ curr_data->charlist = g_strdup (curr_data->chartable->data);
build_table (curr_data);
if (g_settings_is_writable (curr_data->settings, "current-list"))
g_settings_set_string (curr_data->settings,
- "current-list",
+ "current-list",
curr_data->charlist);
}
@@ -197,7 +198,7 @@ edit_palette_cb (GtkDialog *dialog,
if (!new || (g_ascii_strcasecmp (new, charlist) == 0))
return;
-
+
list = g_list_find (curr_data->chartable, charlist);
list->data = new;
save_chartable (curr_data);
@@ -205,7 +206,8 @@ edit_palette_cb (GtkDialog *dialog,
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, new, 1, new, -1);
if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
- curr_data->charlist = new;
+ g_free (curr_data->charlist);
+ curr_data->charlist = g_strdup (new);
build_table (curr_data);
if (g_settings_is_writable (curr_data->settings, "current-list"))
@@ -286,19 +288,20 @@ delete_palette (GtkButton *button,
GtkTreeIter next;
GtkTreeModel *model;
gchar *charlist;
-
+
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (curr_data->pref_tree));
-
+
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return;
-
+
gtk_tree_model_get (model, &iter, 1, &charlist, -1);
curr_data->chartable = g_list_remove (curr_data->chartable, charlist);
if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
+ g_free (curr_data->charlist);
curr_data->charlist = curr_data->chartable != NULL ?
- curr_data->chartable->data : "";
+ g_strdup (curr_data->chartable->data) : g_strdup ("");
if (g_settings_is_writable (curr_data->settings, "current-list"))
g_settings_set_string (curr_data->settings,
"current-list",