pidgin: 212bc09a: A leak fix in the candidate list, and so...

sadrul at pidgin.im sadrul at pidgin.im
Mon Oct 12 04:25:59 EDT 2009


-----------------------------------------------------------------
Revision: 212bc09a34357ebea13972d105b0aa4da3e65b5f
Ancestor: 1bea728ca994400e3cfc0ee7183e946ddaff6b09
Author: sadrul at pidgin.im
Date: 2009-10-10T19:44:44
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/212bc09a34357ebea13972d105b0aa4da3e65b5f

Modified files:
        libpurple/protocols/jabber/google.c
        libpurple/protocols/jabber/jabber.c

ChangeLog: 

A leak fix in the candidate list, and some code simplification.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google.c	0f2d813acefad8eb343eac7f2d7a5fd6935940f9
+++ libpurple/protocols/jabber/google.c	5c0ce14647fde25a1bc8d119a58de540af020aae
@@ -95,14 +95,14 @@ google_session_send_candidates(PurpleMed
 		gchar *participant, GoogleSession *session)
 {
 	GList *candidates = purple_media_get_local_candidates(
-			session->media, session_id, session->remote_jid);
+			session->media, session_id, session->remote_jid), *iter;
 	PurpleMediaCandidate *transport;
 	gboolean video = FALSE;
 
 	if (!strcmp(session_id, "google-video"))
 		video = TRUE;
 
-	for (;candidates;candidates = candidates->next) {
+	for (iter = candidates; iter; iter = iter->next) {
 		JabberIq *iq;
 		gchar *ip, *port, *username, *password;
 		gchar pref[16];
@@ -110,7 +110,7 @@ google_session_send_candidates(PurpleMed
 		xmlnode *sess;
 		xmlnode *candidate;
 		guint component_id;
-		transport = (PurpleMediaCandidate*)(candidates->data);
+		transport = PURPLE_MEDIA_CANDIDATE(iter->data);
 		component_id = purple_media_candidate_get_component_id(
 				transport);
 
@@ -168,6 +168,7 @@ google_session_send_candidates(PurpleMed
 
 		jabber_iq_send(iq);
 	}
+	purple_media_candidate_list_free(candidates);
 }
 
 static void
============================================================
--- libpurple/protocols/jabber/jabber.c	48102aa81249a4119a5f1db126bf4d8c0f667dbd
+++ libpurple/protocols/jabber/jabber.c	58903e8327dcfcc0cba899eea5097f3b3da68e8a
@@ -1079,39 +1079,19 @@ jabber_register_cb(JabberRegisterCBData 
 					return;
 				}
 			} else {
+				const char *ids[] = {"username", "password", "name", "email", "nick", "first",
+					"last", "address", "city", "state", "zip", "phone", "url", "date",
+					NULL};
 				const char *value = purple_request_field_string_get_value(field);
+				int i;
+				for (i = 0; ids[i]; i++) {
+					if (!strcmp(id, ids[i]))
+						break;
+				}
 
-				if(!strcmp(id, "username")) {
-					y = xmlnode_new_child(query, "username");
-				} else if(!strcmp(id, "password")) {
-					y = xmlnode_new_child(query, "password");
-				} else if(!strcmp(id, "name")) {
-					y = xmlnode_new_child(query, "name");
-				} else if(!strcmp(id, "email")) {
-					y = xmlnode_new_child(query, "email");
-				} else if(!strcmp(id, "nick")) {
-					y = xmlnode_new_child(query, "nick");
-				} else if(!strcmp(id, "first")) {
-					y = xmlnode_new_child(query, "first");
-				} else if(!strcmp(id, "last")) {
-					y = xmlnode_new_child(query, "last");
-				} else if(!strcmp(id, "address")) {
-					y = xmlnode_new_child(query, "address");
-				} else if(!strcmp(id, "city")) {
-					y = xmlnode_new_child(query, "city");
-				} else if(!strcmp(id, "state")) {
-					y = xmlnode_new_child(query, "state");
-				} else if(!strcmp(id, "zip")) {
-					y = xmlnode_new_child(query, "zip");
-				} else if(!strcmp(id, "phone")) {
-					y = xmlnode_new_child(query, "phone");
-				} else if(!strcmp(id, "url")) {
-					y = xmlnode_new_child(query, "url");
-				} else if(!strcmp(id, "date")) {
-					y = xmlnode_new_child(query, "date");
-				} else {
+				if (!ids[i])
 					continue;
-				}
+				y = xmlnode_new_child(query, ids[i]);
 				xmlnode_insert_data(y, value, -1);
 				if(cbdata->js->registration && !strcmp(id, "username")) {
 					g_free(cbdata->js->user->node);


More information about the Commits mailing list