diff libpurple/protocols/silc/silc.c @ 22687:757a571ae9be

Don't access uninitialized memory (I think this might actually fix some silc connection oddness I've been seeing too), and a leak fix or two.
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 23 Apr 2008 14:54:00 +0000
parents 665e04562de0
children 3d092dd95ec1
line wrap: on
line diff
--- a/libpurple/protocols/silc/silc.c	Wed Apr 23 10:25:53 2008 +0000
+++ b/libpurple/protocols/silc/silc.c	Wed Apr 23 14:54:00 2008 +0000
@@ -380,14 +380,6 @@
 
 	client = sg->client;
 
-	/* Progress */
-	if (params.detach_data) {
-		purple_connection_update_progress(gc, _("Resuming session"), 2, 5);
-		sg->resuming = TRUE;
-	} else {
-		purple_connection_update_progress(gc, _("Performing key exchange"), 2, 5);
-	}
-
 	/* Get session detachment data, if available */
 	memset(&params, 0, sizeof(params));
 	dfile = silcpurple_session_file(purple_account_get_username(sg->account));
@@ -397,6 +389,14 @@
 	params.ignore_requested_attributes = FALSE;
 	params.pfs = purple_account_get_bool(sg->account, "pfs", FALSE);
 
+	/* Progress */
+	if (params.detach_data) {
+		purple_connection_update_progress(gc, _("Resuming session"), 2, 5);
+		sg->resuming = TRUE;
+	} else {
+		purple_connection_update_progress(gc, _("Performing key exchange"), 2, 5);
+	}
+
 	/* Perform SILC Key Exchange. */
 	silc_client_key_exchange(sg->client, &params, sg->public_key,
 				 sg->private_key, stream, SILC_CONN_SERVER,
@@ -550,8 +550,12 @@
 		                             _("Cannot initialize SILC protocol"));
 		gc->proto_data = NULL;
 		silc_free(sg);
+		free(hostname);
+		free(username);
 		return;
 	}
+	free(hostname);
+	free(username);
 
 	/* Check the ~/.silc dir and create it, and new key pair if necessary. */
 	if (!silcpurple_check_silc_dir(gc)) {