[geany/geany] aa4025: Fix invalid memory access when quitting

Colomban Wendling git-noreply at xxxxx
Wed Jul 1 21:03:38 UTC 2015

Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 01 Jul 2015 21:03:38 UTC
Commit:      aa40250fdab5b1b5867b48a19d12c2a9cf2ecf7b

Log Message:
Fix invalid memory access when quitting

When quitting and the prefs dialog has been created, the StashPrefs are
destroyed before the stash tree and so the stash tree cleanup code
accesses freed memory.  Fix this by removing access to the StashPref in
the tree cleanup code, as fixing it properly is a bit of a mess.

Closes #538.

Modified Paths:

Modified: src/stash.c
6 lines changed, 3 insertions(+), 3 deletions(-)
@@ -979,7 +979,7 @@ struct StashTreeValue
 	const gchar *group_name;
 	StashPref *pref;
-	union
+	struct
 		gchararray tree_string;
 		gint tree_int;
@@ -1075,8 +1075,8 @@ static gboolean stash_tree_discard_value(GtkTreeModel *model, GtkTreePath *path,
 	StashTreeValue *value;
 	gtk_tree_model_get(model, iter, STASH_TREE_VALUE, &value, -1);
-	if (value->pref->setting_type == G_TYPE_STRING)
-		g_free(value->data.tree_string);
+	/* don't access value->pref as it might already have been freed */
+	g_free(value->data.tree_string);
 	return FALSE;

This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).

More information about the Commits mailing list