From 10f7cb24b26d1a62cdf4851788e4363efacb1b78 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jir=CC=8Ci=CC=81=20Techet?= Date: Wed, 4 Nov 2015 12:50:57 +0100 Subject: [PATCH] Avoid possible invalid memory access when activating plugin It may happen (and happens on OS X) that plugin activation using plugin_new() triggers some action which causes the tree view to update. However, as the old plugin was freed before, the tree view contains an invalid pointer to p which causes invalid memory access. After freeing the old pointer, set the tree view value to NULL - the plugin pointer is checked at other places for NULL value so it doesn't crash. --- src/plugins.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins.c b/src/plugins.c index e6594b2fe..4ac771f8c 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -1478,6 +1478,9 @@ static void pm_plugin_toggled(GtkCellRendererToggle *cell, gchar *pth, gpointer /* save shortcuts (only need this group, but it doesn't take long) */ keybindings_write_to_file(); + /* plugin_new() below may cause a tree view refresh with invalid p - set to NULL */ + gtk_tree_store_set(pm_widgets.store, &store_iter, + PLUGIN_COLUMN_PLUGIN, NULL, -1); plugin_free(p); /* reload plugin module and initialize it if item is checked */ -- 2.11.4.GIT