pidgin: 5430f29f: Free some memory if we exit early due to...

markdoliner at pidgin.im markdoliner at pidgin.im
Fri Mar 27 05:10:34 EDT 2009


-----------------------------------------------------------------
Revision: 5430f29f5323572b9515c26bcae3a3b87be8e474
Ancestor: 9d9ccad79e30da52d052e497361b56c6387d0690
Author: markdoliner at pidgin.im
Date: 2009-03-27T09:09:00
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5430f29f5323572b9515c26bcae3a3b87be8e474

Modified files:
        libpurple/plugins/mono/loader/mono.c

ChangeLog: 

Free some memory if we exit early due to an error.  Thanks to
Mayank Jain Nawal's email to the devel list for pointing this
out.  Oh, and I didn't test these changes at all... I guess I
probably should.

-------------- next part --------------
============================================================
--- libpurple/plugins/mono/loader/mono.c	cf7597f0336dbea83156972b3cb8565f050bda1d
+++ libpurple/plugins/mono/loader/mono.c	7e62abb81d2e5519ca769e2b7f14f366b4124203
@@ -44,11 +44,11 @@ static gboolean probe_mono_plugin(Purple
 	purple_debug(PURPLE_DEBUG_INFO, "mono", "Probing plugin\n");
 
 	if (ml_is_api_dll(mono_assembly_get_image(assm))) {
-		purple_debug(PURPLE_DEBUG_INFO, "mono", "Found our PurpleAPI.dll\n");
+		purple_debug_info("mono", "Found our PurpleAPI.dll\n");
+		mono_assembly_close(assm);
 		return FALSE;
 	}
 
-	info = g_new0(PurplePluginInfo, 1);
 	mplug = g_new0(PurpleMonoPlugin, 1);
 
 	mplug->signal_data = NULL;
@@ -58,12 +58,16 @@ static gboolean probe_mono_plugin(Purple
 	mplug->klass = ml_find_plugin_class(mono_assembly_get_image(mplug->assm));
 	if (!mplug->klass) {
 		purple_debug(PURPLE_DEBUG_ERROR, "mono", "no plugin class in \'%s\'\n", file);
+		mono_assembly_close(assm);
+		g_free(mplug);
 		return FALSE;
 	}
 
 	mplug->obj = mono_object_new(ml_get_domain(), mplug->klass);
 	if (!mplug->obj) {
 		purple_debug(PURPLE_DEBUG_ERROR, "mono", "obj not valid\n");
+		mono_assembly_close(assm);
+		g_free(mplug);
 		return FALSE;
 	}
 
@@ -85,6 +89,8 @@ static gboolean probe_mono_plugin(Purple
 
 	if (!(found_load && found_unload && found_destroy)) {
 		purple_debug(PURPLE_DEBUG_ERROR, "mono", "did not find the required methods\n");
+		mono_assembly_close(assm);
+		g_free(mplug);
 		return FALSE;
 	}
 
@@ -93,6 +99,7 @@ static gboolean probe_mono_plugin(Purple
 	/* now that the methods are filled out we can populate
 	   the info struct with all the needed info */
 
+	info = g_new0(PurplePluginInfo, 1);
 	info->id = ml_get_prop_string(plugin_info, "Id");
 	info->name = ml_get_prop_string(plugin_info, "Name");
 	info->version = ml_get_prop_string(plugin_info, "Version");


More information about the Commits mailing list