/soc/2013/ankitkv/gobjectification: 1945ae79bbb3: Added checks i...

Ankit Vani a at nevitus.org
Thu Aug 8 14:49:43 EDT 2013


Changeset: 1945ae79bbb332a66a521c227b8fe85409cd31df
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-08-09 00:19 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/1945ae79bbb3

Description:

Added checks in case a plugin does not return a PluginInfo

diffstat:

 libpurple/plugins.c |  24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diffs (95 lines):

diff --git a/libpurple/plugins.c b/libpurple/plugins.c
--- a/libpurple/plugins.c
+++ b/libpurple/plugins.c
@@ -125,6 +125,8 @@ purple_plugin_unload(PurplePlugin *plugi
 
 	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(purple_plugin_get_info(plugin));
 
+	g_return_val_if_fail(priv != NULL, FALSE);
+
 	purple_debug_info("plugins", "Unloading plugin %s\n",
 			purple_plugin_get_filename(plugin));
 
@@ -253,6 +255,8 @@ purple_plugin_add_action(PurplePlugin *p
 
 	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(purple_plugin_get_info(plugin));
 
+	g_return_if_fail(priv != NULL);
+
 	action = g_new0(PurplePluginAction, 1);
 
 	action->label    = g_strdup(label);
@@ -265,13 +269,11 @@ purple_plugin_add_action(PurplePlugin *p
 GList *
 purple_plugin_get_actions(const PurplePlugin *plugin)
 {
-	PurplePluginInfo *info;
 	PurplePluginInfoPrivate *priv;
 
 	g_return_val_if_fail(plugin != NULL, NULL);
 
-	info = purple_plugin_get_info(plugin);
-	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(purple_plugin_get_info(plugin));
 
 	g_return_val_if_fail(priv != NULL, NULL);
 
@@ -287,6 +289,9 @@ purple_plugin_is_internal(const PurplePl
 	g_return_val_if_fail(plugin != NULL, FALSE);
 
 	info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+
+	g_return_val_if_fail(info != NULL, FALSE);
+
 	return (gplugin_plugin_info_get_flags(info) &
 	        GPLUGIN_PLUGIN_INFO_FLAGS_INTERNAL);
 
@@ -298,13 +303,11 @@ purple_plugin_is_internal(const PurplePl
 gboolean
 purple_plugin_is_loadable(const PurplePlugin *plugin)
 {
-	PurplePluginInfo *info;
 	PurplePluginInfoPrivate *priv;
 
 	g_return_val_if_fail(plugin != NULL, FALSE);
 
-	info = purple_plugin_get_info(plugin);
-	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(purple_plugin_get_info(plugin));
 
 	g_return_val_if_fail(priv != NULL, FALSE);
 
@@ -314,13 +317,11 @@ purple_plugin_is_loadable(const PurplePl
 gchar *
 purple_plugin_get_error(const PurplePlugin *plugin)
 {
-	PurplePluginInfo *info;
 	PurplePluginInfoPrivate *priv;
 
 	g_return_val_if_fail(plugin != NULL, NULL);
 
-	info = purple_plugin_get_info(plugin);
-	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(info);
+	priv = PURPLE_PLUGIN_INFO_GET_PRIVATE(purple_plugin_get_info(plugin));
 
 	g_return_val_if_fail(priv != NULL, NULL);
 
@@ -803,6 +804,8 @@ purple_plugins_refresh(void)
 			continue;
 
 		info = GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
+		if (!info)
+			continue;
 
 		if (gplugin_plugin_info_get_flags(info) &
 				GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY) {
@@ -870,6 +873,9 @@ purple_plugins_save_loaded(const char *k
 		GPluginPluginInfo *info =
 				GPLUGIN_PLUGIN_INFO(purple_plugin_get_info(plugin));
 
+		if (!info)
+			continue;
+
 		if (gplugin_plugin_info_get_flags(info) &
 				GPLUGIN_PLUGIN_INFO_FLAGS_LOAD_ON_QUERY)
 			continue;



More information about the Commits mailing list