pidgin: f9080d0b: correctly NULL terminate all the arrays ...
khc at pidgin.im
khc at pidgin.im
Sun May 10 18:10:27 EDT 2009
-----------------------------------------------------------------
Revision: f9080d0b3274907da710c3d4d85669464e418ba4
Ancestor: b64b40b3762950d0b8b4bff4f4bb8bddeefc24ac
Author: khc at pidgin.im
Date: 2009-05-10T22:06:08
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/f9080d0b3274907da710c3d4d85669464e418ba4
Modified files:
libpurple/protocols/jabber/google.c
libpurple/protocols/msn/notification.c
libpurple/protocols/msn/oim.c
libpurple/protocols/msnp9/notification.c
libpurple/protocols/myspace/myspace.c
libpurple/protocols/oscar/oscar.c
libpurple/protocols/yahoo/yahoo.c
ChangeLog:
correctly NULL terminate all the arrays since that's what gtknotify assumes,
also fixed a memory leak in gmail notification
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/google.c e17f7f655907c739c4668a8a638331e45c4c83a8
+++ libpurple/protocols/jabber/google.c 2d780f0a82cc28396404a82084f1fe8f78aa931d
@@ -638,7 +638,6 @@ jabber_gmail_parse(JabberStream *js, con
const char *to, *url;
const char *in_str;
char *to_name;
- char *default_tos[1];
int i, count = 1, returned_count;
@@ -658,14 +657,20 @@ jabber_gmail_parse(JabberStream *js, con
/* 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;
}
@@ -673,10 +678,10 @@ jabber_gmail_parse(JabberStream *js, con
* 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);
@@ -726,16 +731,12 @@ jabber_gmail_parse(JabberStream *js, con
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 < count; i++)
+ g_free(subjects[i]);
g_free(subjects);
g_free(urls);
============================================================
--- libpurple/protocols/msn/notification.c ccab50d1b462bbe6f5fe8216e9932bb0db31dee2
+++ libpurple/protocols/msn/notification.c ee98bf7521b0fdc8c96515fc22aa41d9f50da304
@@ -1891,14 +1891,11 @@ initial_email_msg(MsnCmdProc *cmdproc, M
if (count > 0)
{
- const char *passport;
- const char *url;
+ const char *passports[2] = { msn_user_get_passport(session->user) };
+ const char *urls[2] = { session->passport_info.mail_url };
- passport = msn_user_get_passport(session->user);
- url = session->passport_info.mail_url;
-
purple_notify_emails(gc, count, FALSE, NULL, NULL,
- &passport, &url, NULL, NULL);
+ passports, urls, NULL, NULL);
}
}
@@ -1960,14 +1957,11 @@ initial_mdata_msg(MsnCmdProc *cmdproc, M
if (count > 0)
{
- const char *passport;
- const char *url;
+ const char *passports[2] = { msn_user_get_passport(session->user) };
+ const char *urls[2] = { session->passport_info.mail_url };
- passport = msn_user_get_passport(session->user);
- url = session->passport_info.mail_url;
-
purple_notify_emails(gc, count, FALSE, NULL, NULL,
- &passport, &url, NULL, NULL);
+ passports, urls, NULL, NULL);
}
}
============================================================
--- libpurple/protocols/msn/oim.c a4f8576acc6135d6275bbf71675c760b7c8d7b44
+++ libpurple/protocols/msn/oim.c 503ce225a1b7b52e494be8d79ecbec8ceddb146c
@@ -764,14 +764,14 @@ msn_parse_oim_xml(MsnOim *oim, xmlnode *
if (iu_node != NULL && purple_account_get_check_mail(session->account))
{
char *unread = xmlnode_get_data(iu_node);
- const char *passport = msn_user_get_passport(session->user);
- const char *url = session->passport_info.mail_url;
+ const char *passports[2] = { msn_user_get_passport(session->user) };
+ const char *urls[2] = { session->passport_info.mail_url };
int count = atoi(unread);
/* XXX/khc: pretty sure this is wrong */
if (count > 0)
purple_notify_emails(session->account->gc, count, FALSE, NULL,
- NULL, &passport, &url, NULL, NULL);
+ NULL, passports, urls, NULL, NULL);
g_free(unread);
}
============================================================
--- libpurple/protocols/msnp9/notification.c e93ac247f6cd58a84db21287ff78e6d35c8697fa
+++ libpurple/protocols/msnp9/notification.c 2f99e8cc5ad2beb7019ae007e46cab2ff860fd22
@@ -1280,14 +1280,11 @@ initial_email_msg(MsnCmdProc *cmdproc, M
if (count > 0)
{
- const char *passport;
- const char *url;
+ const char *passports[2] = { msn_user_get_passport(session->user) };
+ const char *urls[2] = { session->passport_info.file };
- passport = msn_user_get_passport(session->user);
- url = session->passport_info.file;
-
- purple_notify_emails(gc, atoi(unread), FALSE, NULL, NULL,
- &passport, &url, NULL, NULL);
+ purple_notify_emails(gc, count, FALSE, NULL, NULL,
+ passports, urls, NULL, NULL);
}
}
============================================================
--- libpurple/protocols/myspace/myspace.c 7e742b67d053a10d627af7d18b87b0a57887812c
+++ libpurple/protocols/myspace/myspace.c 67e505fcd6dc9d690b5d31fbe267be2f68fa1d0c
@@ -847,8 +847,6 @@ msim_check_inbox_cb(MsimSession *session
MsimMessage *body;
guint old_inbox_status;
guint i, n;
- const gchar *froms[5], *tos[5], *urls[5], *subjects[5];
-
/* Information for each new inbox message type. */
static struct
{
@@ -863,16 +861,22 @@ msim_check_inbox_cb(MsimSession *session
{ "FriendRequest", MSIM_INBOX_FRIEND_REQUEST, "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", NULL },
{ "PictureComment", MSIM_INBOX_PICTURE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL }
};
+ const gchar *froms[ARRAY_LENGTH(message_types) + 1] = { "" },
+ *tos[ARRAY_LENGTH(message_types) + 1] = { "" },
+ *urls[ARRAY_LENGTH(message_types) + 1] = { "" },
+ *subjects[ARRAY_LENGTH(message_types) + 1] = { "" };
+ g_return_if_fail(reply != NULL);
+
/* Can't write _()'d strings in array initializers. Workaround. */
+ /* khc: then use N_() in the array initializer and use _() when they are
+ used */
message_types[0].text = _("New mail messages");
message_types[1].text = _("New blog comments");
message_types[2].text = _("New profile comments");
message_types[3].text = _("New friend requests!");
message_types[4].text = _("New picture comments");
- g_return_if_fail(reply != NULL);
-
body = msim_msg_get_dictionary(reply, "body");
if (body == NULL)
============================================================
--- libpurple/protocols/oscar/oscar.c c2eb89efb14f60dbcff5483db0e8113d075317bf
+++ libpurple/protocols/oscar/oscar.c 467fdaa45435cdcde7b5ee2c7806df8f484b5221
@@ -3571,8 +3571,10 @@ static int purple_email_parseupdate(Osca
purple_account_get_username(account),
emailinfo->domain ? "@" : "",
emailinfo->domain ? emailinfo->domain : "");
+ const char *tos[2] = { to };
+ const char *urls[2] = { emailinfo->url };
purple_notify_emails(gc, emailinfo->nummsgs, FALSE, NULL, NULL,
- (const char **)&to, (const char **)&emailinfo->url, NULL, NULL);
+ tos, urls, NULL, NULL);
g_free(to);
}
============================================================
--- libpurple/protocols/yahoo/yahoo.c e55a2de00eb1107425a90f982389ed96af3ae3fb
+++ libpurple/protocols/yahoo/yahoo.c 0246ab1b4d07cf6ac05016eed7d45fd8c4bcb079
@@ -1520,10 +1520,10 @@ static void yahoo_process_mail(PurpleCon
g_free(dec_subj);
g_free(from);
} else if (count > 0) {
- const char *to = purple_account_get_username(account);
- const char *url = yahoo_mail_url;
+ const char *tos[2] = { purple_account_get_username(account) };
+ const char *urls[2] = { yahoo_mail_url };
- purple_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url,
+ purple_notify_emails(gc, count, FALSE, NULL, NULL, tos, urls,
NULL, NULL);
}
}
More information about the Commits
mailing list