Mercurial > pidgin
comparison libpurple/protocols/jabber/presence.c @ 29623:40fee5f86bf8
jabber: Proper memory management (and fix a segfault) and whitespace
(Was freeing the nickname twice and not freeing the status codes at all)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 20 Mar 2010 16:20:09 +0000 |
parents | ffc1f997cb91 |
children | 9f59abd49def |
comparison
equal
deleted
inserted
replaced
29605:ffc1f997cb91 | 29623:40fee5f86bf8 |
---|---|
668 jid = xmlnode_get_attrib(presence->chat_info.item, "jid"); | 668 jid = xmlnode_get_attrib(presence->chat_info.item, "jid"); |
669 | 669 |
670 if (chat->muc) { | 670 if (chat->muc) { |
671 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110))) | 671 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(110))) |
672 is_our_resource = TRUE; | 672 is_our_resource = TRUE; |
673 | 673 |
674 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) { | 674 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(301))) { |
675 /* XXX: We got banned. YAY! (No GIR, that's bad) */ | 675 /* XXX: We got banned. YAY! (No GIR, that's bad) */ |
676 } | 676 } |
677 | 677 |
678 | 678 |
742 g_free(presence->status); | 742 g_free(presence->status); |
743 presence->status = tmp; | 743 presence->status = tmp; |
744 | 744 |
745 g_free(reason); | 745 g_free(reason); |
746 } | 746 } |
747 | 747 |
748 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(321))) { | 748 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(321))) { |
749 /* XXX: removed due to an affiliation change */ | 749 /* XXX: removed due to an affiliation change */ |
750 } | 750 } |
751 | 751 |
752 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(322))) { | 752 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(322))) { |
753 /* XXX: removed because room is now members-only */ | 753 /* XXX: removed because room is now members-only */ |
754 } | 754 } |
755 | 755 |
756 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(332))) { | 756 if (g_slist_find(presence->chat_info.codes, GINT_TO_POINTER(332))) { |
757 /* XXX: removed due to system shutdown */ | 757 /* XXX: removed due to system shutdown */ |
758 } | 758 } |
759 } | 759 } |
760 | 760 |
994 for (child = packet->child; child; child = child->next) { | 994 for (child = packet->child; child; child = child->next) { |
995 char *key; | 995 char *key; |
996 JabberPresenceHandler *pih; | 996 JabberPresenceHandler *pih; |
997 if (child->type != XMLNODE_TYPE_TAG) | 997 if (child->type != XMLNODE_TYPE_TAG) |
998 continue; | 998 continue; |
999 | 999 |
1000 key = g_strdup_printf("%s %s", child->name, xmlnode_get_namespace(child)); | 1000 key = g_strdup_printf("%s %s", child->name, xmlnode_get_namespace(child)); |
1001 pih = g_hash_table_lookup(presence_handlers, key); | 1001 pih = g_hash_table_lookup(presence_handlers, key); |
1002 g_free(key); | 1002 g_free(key); |
1003 if (pih) | 1003 if (pih) |
1004 pih(js, &presence, child); | 1004 pih(js, &presence, child); |
1050 } | 1050 } |
1051 } | 1051 } |
1052 } | 1052 } |
1053 | 1053 |
1054 out: | 1054 out: |
1055 while (presence.chat_info.codes) | |
1056 presence.chat_info.codes = | |
1057 g_slist_delete_link(presence.chat_info.codes, | |
1058 presence.chat_info.codes); | |
1059 | |
1060 g_free(presence.status); | |
1061 g_free(presence.vcard_avatar_hash); | |
1055 g_free(presence.nickname); | 1062 g_free(presence.nickname); |
1056 g_free(presence.status); | |
1057 jabber_id_free(presence.jid_from); | 1063 jabber_id_free(presence.jid_from); |
1058 g_free(presence.nickname); | |
1059 g_free(presence.vcard_avatar_hash); | |
1060 } | 1064 } |
1061 | 1065 |
1062 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) | 1066 void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type) |
1063 { | 1067 { |
1064 xmlnode *presence = xmlnode_new("presence"); | 1068 xmlnode *presence = xmlnode_new("presence"); |