pidgin: fcc261c8: Fix some double-frees and/or leaks.

qulogic at pidgin.im qulogic at pidgin.im
Fri May 21 18:07:32 EDT 2010


-----------------------------------------------------------------
Revision: fcc261c83e17bf1de125391ba4c14fb6245ecde4
Ancestor: 82503e2352b6ec1b80e8a1b52c7ff0b695f32f5e
Author: qulogic at pidgin.im
Date: 2010-04-19T07:41:56
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/fcc261c83e17bf1de125391ba4c14fb6245ecde4

Modified files:
        libpurple/protocols/msn/slp.c

ChangeLog: 

Fix some double-frees and/or leaks.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/slp.c	d4da6588ce1c6e12e7b06fbb2c0e81488520365b
+++ libpurple/protocols/msn/slp.c	1c425e0a51c51b08db5e562f64a3369c82d5ed32
@@ -327,8 +327,9 @@ msn_slp_process_transresp(MsnSlpCall *sl
 msn_slp_process_transresp(MsnSlpCall *slpcall, const char *content)
 {
 	/* A direct connection negotiation response */
-	char		*bridge;
-	MsnDirectConn	*dc = slpcall->slplink->dc;
+	char *bridge;
+	MsnDirectConn *dc = slpcall->slplink->dc;
+	gboolean result = FALSE;
 
 	purple_debug_info("msn", "process_transresp\n");
 
@@ -336,7 +337,7 @@ msn_slp_process_transresp(MsnSlpCall *sl
 	g_return_val_if_fail(dc->state == DC_STATE_CLOSED, FALSE);
 
 	bridge = get_token(content, "Bridge: ", "\r\n");
-	if(bridge && strcmp(bridge, "TCPv1") == 0) {
+	if (bridge && !strcmp(bridge, "TCPv1")) {
 		/* Ok, the client supports direct TCP connection */
 
 		if (dc->listen_data != NULL || dc->listenfd != -1) {
@@ -354,15 +355,13 @@ msn_slp_process_transresp(MsnSlpCall *sl
 				msn_dc_send_invite(dc);
 			}
 
-			return TRUE;
-
 		} else {
 			/*
 			 * We should connect to the client so parse
 			 * IP/port from response.
 			 */
-			char		*ip, *port_str;
-			int		port = 0;
+			char *ip, *port_str;
+			int port = 0;
 
 			/* Save external IP/port for later use. We'll try local connection first. */
 			dc->ext_ip = get_token(content, "IPv4External-Addrs: ", "\r\n");
@@ -397,32 +396,27 @@ msn_slp_process_transresp(MsnSlpCall *sl
 						msn_dc_outgoing_connection_timeout_cb,
 						dc
 					);
-					return TRUE;
-
 				} else {
 					/*
 					 * Connection failed
 					 * Try external IP/port (if specified)
 					 */
 					msn_dc_outgoing_connection_timeout_cb(dc);
-					return TRUE;
 				}
 
-				g_free(ip);
-
 			} else {
 				/*
 				 * Omitted or invalid internal IP address / port
 				 * Try external IP/port (if specified)
 				 */
 				msn_dc_outgoing_connection_timeout_cb(dc);
-				return TRUE;
 			}
 
-			if (ip)
-				g_free(ip);
+			g_free(ip);
 		}
 
+		result = TRUE;
+
 	} else {
 		/*
 		 * Invalid direct connect invitation or
@@ -430,10 +424,9 @@ msn_slp_process_transresp(MsnSlpCall *sl
 		 */
 	}
 
-	if (bridge)
-		g_free(bridge);
+	g_free(bridge);
 
-	return FALSE;
+	return result;
 }
 
 static void


More information about the Commits mailing list