Mercurial > pidgin
diff libpurple/protocols/jabber/google.c @ 25606:2260e5b0ca91
*** Plucked rev f9080d0b (khc@pidgin.im):
correctly NULL terminate all the arrays since that's what gtknotify assumes,
also fixed a memory leak in gmail notification
*** Plucked rev a543de79 (khc@pidgin.im):
Qulogic pointed out that glib has G_N_ELEMENTS already
*** Plucked rev 19b202a7 (khc@pidgin.im):
used the wrong count variable here
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 10 May 2009 23:25:26 +0000 |
parents | e1bddd9c5c88 |
children | 01f1929d0936 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/google.c Wed May 06 18:58:47 2009 +0000 +++ b/libpurple/protocols/jabber/google.c Sun May 10 23:25:26 2009 +0000 @@ -39,7 +39,6 @@ char *subject; const char *in_str; char *to_name; - char *default_tos[1]; int i, count = 1, returned_count; @@ -59,14 +58,20 @@ /* If Gmail doesn't tell us who the mail is to, let's use our JID */ to = xmlnode_get_attrib(packet, "to"); - default_tos[0] = jabber_get_bare_jid(to); message = xmlnode_get_child(child, "mail-thread-info"); if (count == 0 || !message) { - if (count > 0) - purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); - g_free(default_tos[0]); + if (count > 0) { + char *bare_jid = jabber_get_bare_jid(to); + const char *default_tos[2] = { bare_jid }; + + purple_notify_emails(js->gc, count, FALSE, NULL, NULL, default_tos, NULL, NULL, NULL); + g_free(bare_jid); + } else { + purple_notify_emails(js->gc, count, FALSE, NULL, NULL, NULL, NULL, NULL, NULL); + } + return; } @@ -74,10 +79,10 @@ * accordingly */ for (returned_count = 0; message; returned_count++, message=xmlnode_get_next_twin(message)); - froms = g_new0(const char* , returned_count); - tos = g_new0(const char* , returned_count); - subjects = g_new0(char* , returned_count); - urls = g_new0(const char* , returned_count); + froms = g_new0(const char* , returned_count + 1); + tos = g_new0(const char* , returned_count + 1); + subjects = g_new0(char* , returned_count + 1); + urls = g_new0(const char* , returned_count + 1); to = xmlnode_get_attrib(packet, "to"); to_name = jabber_get_bare_jid(to); @@ -123,16 +128,12 @@ if (i>0) purple_notify_emails(js->gc, count, count == i, (const char**) subjects, froms, tos, urls, NULL, NULL); - else - purple_notify_emails(js->gc, count, FALSE, NULL, NULL, (const char**) default_tos, NULL, NULL, NULL); - g_free(to_name); g_free(tos); - g_free(default_tos[0]); g_free(froms); - for (; i > 0; i--) - g_free(subjects[i - 1]); + for (i = 0; i < returned_count; i++) + g_free(subjects[i]); g_free(subjects); g_free(urls);