/pidgin/main: dabb189b6ac9: zephyr.c: Fix multiple leaks

Niels Thykier niels at thykier.net
Sun Jan 27 05:57:49 EST 2013


Changeset: dabb189b6ac98293069056c87ad3cd1895f866af
Author:	 Niels Thykier <niels at thykier.net>
Date:	 2013-01-26 03:51 -0500
Branch:	 default
URL: http://hg.pidgin.im/pidgin/main/rev/dabb189b6ac9

Description:

zephyr.c: Fix multiple leaks

I (QuLogic) have fixed the FIXME from the patch in the function
zephyr_action_get_subs_from_server.

Refs #15472.

diffstat:

 libpurple/protocols/zephyr/zephyr.c |  21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diffs (86 lines):

diff --git a/libpurple/protocols/zephyr/zephyr.c b/libpurple/protocols/zephyr/zephyr.c
--- a/libpurple/protocols/zephyr/zephyr.c
+++ b/libpurple/protocols/zephyr/zephyr.c
@@ -1501,6 +1501,7 @@ static void process_zsubs(zephyr_account
 		}
 		fclose(f);
 	}
+	g_free(fname);
 }
 
 static void process_anyone(PurpleConnection *gc)
@@ -2166,11 +2167,15 @@ static int zephyr_send_message(zephyr_ac
 		len = strlen(zsendstr);
 		result = write(zephyr->totzc[ZEPHYR_FD_WRITE], zsendstr, len);
 		if (result != len) {
+			g_free(tzc_sig);
+			g_free(tzc_body);
 			g_free(zsendstr);
 			g_free(html_buf2);
 			g_free(html_buf);
 			return errno;
 		}
+		g_free(tzc_sig);
+		g_free(tzc_body);
 		g_free(zsendstr);
 	} else if (use_zeph02(zephyr)) {
 		ZNotice_t notice;
@@ -2591,6 +2596,7 @@ static PurpleCmdRet zephyr_purple_cmd_ms
 				      const char *cmd, char **args, char **error, void *data)
 {
 	char *recipient;
+	PurpleCmdRet ret;
 	PurpleConnection *gc = purple_conversation_get_connection(conv);
 	zephyr_account *zephyr = purple_connection_get_protocol_data(gc);;
 	if (!g_ascii_strcasecmp(args[0],"*"))
@@ -2598,13 +2604,17 @@ static PurpleCmdRet zephyr_purple_cmd_ms
 	else
 		recipient = local_zephyr_normalize(zephyr,args[0]);
 
-	if (strlen(recipient) < 1)
+	if (strlen(recipient) < 1) {
+		g_free(recipient);
 		return PURPLE_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */
+	}
 
 	if (zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),""))
-		return PURPLE_CMD_RET_OK;
+		ret = PURPLE_CMD_RET_OK;
 	else
-		return PURPLE_CMD_RET_FAILED;
+		ret = PURPLE_CMD_RET_FAILED;
+	g_free(recipient);
+	return ret;
 }
 
 static PurpleCmdRet zephyr_purple_cmd_zlocate(PurpleConversation *conv,
@@ -2808,10 +2818,12 @@ static void zephyr_action_get_subs_from_
 		title = g_strdup_printf("Server subscriptions for %s", zephyr->username);
 
 		if (zephyr->port == 0) {
+			g_free(title);
 			purple_debug_error("zephyr", "error while retrieving port\n");
 			return;
 		}
 		if ((retval = ZRetrieveSubscriptions(zephyr->port,&nsubs)) != ZERR_NONE) {
+			g_free(title);
 			/* XXX better error handling */
 			purple_debug_error("zephyr", "error while retrieving subscriptions from server\n");
 			return;
@@ -2820,6 +2832,7 @@ static void zephyr_action_get_subs_from_
 			one = 1;
 			if ((retval = ZGetSubscriptions(&subs,&one)) != ZERR_NONE) {
 				/* XXX better error handling */
+				g_free(title);
 				purple_debug_error("zephyr", "error while retrieving individual subscription\n");
 				return;
 			}
@@ -2828,6 +2841,8 @@ static void zephyr_action_get_subs_from_
 					       subs.zsub_recipient);
 		}
 		purple_notify_formatted(gc, title, title, NULL,  subout->str, NULL, NULL);
+		g_free(title);
+		g_string_free(subout, TRUE);
 	} else {
 		/* XXX fix */
 		purple_notify_error(gc,"","tzc doesn't support this action",NULL);



More information about the Commits mailing list