# HG changeset patch # User Elliott Sales de Andrade # Date 1222485648 0 # Node ID c5488f91bf3b79880db0963ae184fb6206c4d1bd # Parent c3dbdb98a11945754d5b0f5fccb15f8789b5d816 Fix a possible xmlnode leak and an extra g_strdup when processing incoming MSN pages. diff -r c3dbdb98a119 -r c5488f91bf3b libpurple/protocols/msn/notification.c --- a/libpurple/protocols/msn/notification.c Fri Sep 26 16:26:56 2008 +0000 +++ b/libpurple/protocols/msn/notification.c Sat Sep 27 03:20:48 2008 +0000 @@ -1060,7 +1060,8 @@ { PurpleConnection *gc; MsnUserList *userlist; - char *who = NULL, *text = NULL; + const char *who = NULL; + char *text = NULL; const char *id = NULL; xmlnode *payloadNode, *from, *msg, *textNode; @@ -1104,13 +1105,18 @@ */ - if (!(payloadNode = xmlnode_from_str(payload, len)) || - !(from = xmlnode_get_child(payloadNode, "FROM")) || - !(msg = xmlnode_get_child(payloadNode, "MSG")) || - !(textNode = xmlnode_get_child(msg, "BODY/TEXT"))) + payloadNode = xmlnode_from_str(payload, len); + if (!payloadNode) return; - who = g_strdup(xmlnode_get_attrib(from, "name")); + if (!(from = xmlnode_get_child(payloadNode, "FROM")) || + !(msg = xmlnode_get_child(payloadNode, "MSG")) || + !(textNode = xmlnode_get_child(msg, "BODY/TEXT"))) { + xmlnode_free(payloadNode); + return; + } + + who = xmlnode_get_attrib(from, "name"); if (!who) return; text = xmlnode_get_data(textNode); @@ -1121,10 +1127,8 @@ MsnUser *user = msn_userlist_find_user_with_mobile_phone(userlist, who + 4); - if(user && user->passport) { - g_free(who); - who = g_strdup(user->passport); - } + if (user && user->passport) + who = user->passport; } id = xmlnode_get_attrib(msg, "id"); @@ -1143,7 +1147,6 @@ } g_free(text); - g_free(who); xmlnode_free(payloadNode); }