From 1145964911d0d7dd5145de6f7b9d4ed8aeeacd79 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 29 Jun 2008 12:11:50 +0100 Subject: Fixed two memory leaks in the MSN module. --- protocols/msn/ns.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'protocols') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index ffaa90a7..fe48f96d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -277,11 +277,25 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) { if( num_parts == 5 ) { - md->buddycount = atoi( cmd[3] ); - md->groupcount = atoi( cmd[4] ); - if( md->groupcount > 0 ) + int i, groupcount; + + groupcount = atoi( cmd[4] ); + if( groupcount > 0 ) + { + /* valgrind says this is leaking memory, I'm guessing + that this happens during server redirects. */ + if( md->grouplist ) + { + for( i = 0; i < md->groupcount; i ++ ) + g_free( md->grouplist[i] ); + g_free( md->grouplist ); + } + + md->groupcount = groupcount; md->grouplist = g_new0( char *, md->groupcount ); + } + md->buddycount = atoi( cmd[3] ); if( !*cmd[3] || md->buddycount == 0 ) msn_logged_in( ic ); } @@ -664,6 +678,9 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int { imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); } + + g_free( inbox ); + g_free( folders ); } else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) { -- cgit v1.2.3