Revision: 2618 http://geany.svn.sourceforge.net/geany/?rev=2618&view=rev Author: ntrel Date: 2008-05-27 07:47:38 -0700 (Tue, 27 May 2008)
Log Message: ----------- Fail to load a plugin if it has no plugin_init() function.
Modified Paths: -------------- trunk/ChangeLog trunk/src/plugins.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2008-05-26 17:24:11 UTC (rev 2617) +++ trunk/ChangeLog 2008-05-27 14:47:38 UTC (rev 2618) @@ -1,3 +1,9 @@ +2008-05-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/plugins.c: + Fail to load a plugin if it has no plugin_init() function. + + 2008-05-26 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/plugins.c:
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2008-05-26 17:24:11 UTC (rev 2617) +++ trunk/src/plugins.c 2008-05-27 14:47:38 UTC (rev 2618) @@ -470,11 +470,8 @@ *plugin_fields = &plugin->fields;
/* start the plugin */ - g_module_symbol(plugin->module, "plugin_init", (void *) &plugin->init); - if (plugin->init != NULL) - plugin->init(&geany_data); - else - geany_debug("Plugin '%s' has no plugin_init() function!", plugin->info.name); + g_return_if_fail(plugin->init); + plugin->init(&geany_data);
/* store some function pointers for later use */ g_module_symbol(plugin->module, "configure", (void *) &plugin->configure); @@ -511,7 +508,7 @@ }
-/* Load and init a plugin. +/* Load and optionally init a plugin. * init_plugin decides whether the plugin's plugin_init() function should be called or not. If it is * called, the plugin will be started, if not the plugin will be read only (for the list of * available plugins in the plugin manager). @@ -590,6 +587,18 @@ g_free(plugin); return NULL; } + + g_module_symbol(module, "plugin_init", (void *) &plugin->init); + if (plugin->init == NULL) + { + geany_debug("Plugin '%s' has no plugin_init() function - ignoring plugin!", + plugin->info.name); + + if (! g_module_close(module)) + g_warning("%s: %s", fname, g_module_error()); + g_free(plugin); + return NULL; + } geany_debug("Initializing plugin '%s'", plugin->info.name);
plugin->filename = g_strdup(fname);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.