Mercurial > pidgin.yaz
changeset 24127:c5488f91bf3b
Fix a possible xmlnode leak and an extra g_strdup when processing
incoming MSN pages.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 27 Sep 2008 03:20:48 +0000 |
parents | c3dbdb98a119 |
children | 345ed41d807b |
files | libpurple/protocols/msn/notification.c |
diffstat | 1 files changed, 14 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ </NOTIFICATION> */ - 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); }