pidgin: 86eb900c: Fix a leak in myspace prpl.
sadrul at pidgin.im
sadrul at pidgin.im
Wed Dec 17 15:50:40 EST 2008
-----------------------------------------------------------------
Revision: 86eb900cf982408bb630159b662426812328a78c
Ancestor: 33d3e7b191d6c22d10b2ee99b24b42358ea9f4a9
Author: sadrul at pidgin.im
Date: 2008-12-17T20:50:49
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/86eb900cf982408bb630159b662426812328a78c
Modified files:
libpurple/protocols/myspace/message.c
libpurple/protocols/myspace/message.h
libpurple/protocols/myspace/myspace.c
libpurple/protocols/myspace/user.c
libpurple/protocols/myspace/user.h
ChangeLog:
Fix a leak in myspace prpl.
In myspace.c:msim_process_reply, the clone of 'msg' sent to the callbacks
were never freed. Also, do not unnecessarily dup a static string (which
needs to be marked for translation after the string freeze).
-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/message.c 5541e470027bf6a736c95383d719fc7b1e804a65
+++ libpurple/protocols/myspace/message.c b0ea8730d74bb60bdd308f895e2b7b8f2a0fadad
@@ -401,7 +401,7 @@ static GList *
*
*/
static GList *
-msim_msg_get_node(MsimMessage *msg, const gchar *name)
+msim_msg_get_node(const MsimMessage *msg, const gchar *name)
{
GList *node;
@@ -410,7 +410,7 @@ msim_msg_get_node(MsimMessage *msg, cons
}
/* Linear search for the given name. O(n) but n is small. */
- for (node = msg; node != NULL; node = g_list_next(node)) {
+ for (node = (GList*)msg; node != NULL; node = g_list_next(node)) {
MsimMessageElement *elem;
elem = (MsimMessageElement *)node->data;
@@ -1066,7 +1066,7 @@ MsimMessageElement *
* another msim_msg_get_* that converts the data to what type you want.
*/
MsimMessageElement *
-msim_msg_get(MsimMessage *msg, const gchar *name)
+msim_msg_get(const MsimMessage *msg, const gchar *name)
{
GList *node;
@@ -1115,7 +1115,7 @@ gchar *
* This function unescapes the string for you, if needed.
*/
gchar *
-msim_msg_get_string(MsimMessage *msg, const gchar *name)
+msim_msg_get_string(const MsimMessage *msg, const gchar *name)
{
MsimMessageElement *elem;
@@ -1185,7 +1185,7 @@ GList *
* Return an element as a new list. Caller frees with msim_msg_list_free().
*/
GList *
-msim_msg_get_list(MsimMessage *msg, const gchar *name)
+msim_msg_get_list(const MsimMessage *msg, const gchar *name)
{
MsimMessageElement *elem;
@@ -1279,7 +1279,7 @@ MsimMessage *
* Return an element as a new dictionary. Caller frees with msim_msg_free().
*/
MsimMessage *
-msim_msg_get_dictionary(MsimMessage *msg, const gchar *name)
+msim_msg_get_dictionary(const MsimMessage *msg, const gchar *name)
{
MsimMessageElement *elem;
@@ -1321,7 +1321,7 @@ guint
* be converted handled correctly, for example.
*/
guint
-msim_msg_get_integer(MsimMessage *msg, const gchar *name)
+msim_msg_get_integer(const MsimMessage *msg, const gchar *name)
{
MsimMessageElement *elem;
@@ -1398,7 +1398,7 @@ gboolean
* @return TRUE if successful, FALSE if not.
*/
gboolean
-msim_msg_get_binary(MsimMessage *msg, const gchar *name,
+msim_msg_get_binary(const MsimMessage *msg, const gchar *name,
gchar **binary_data, gsize *binary_length)
{
MsimMessageElement *elem;
============================================================
--- libpurple/protocols/myspace/message.h 661cb0c755874fa95db72bc7a29bd37e9ce78c07
+++ libpurple/protocols/myspace/message.h 198327f50230cf0dc559c2dceb5e7c6169021406
@@ -93,14 +93,14 @@ MsimMessage *msim_parse(const gchar *raw
MsimMessage *msim_parse(const gchar *raw);
-MsimMessageElement *msim_msg_get(MsimMessage *msg, const gchar *name);
+MsimMessageElement *msim_msg_get(const MsimMessage *msg, const gchar *name);
/* Retrieve data by name */
-gchar *msim_msg_get_string(MsimMessage *msg, const gchar *name);
-GList *msim_msg_get_list(MsimMessage *msg, const gchar *name);
-MsimMessage *msim_msg_get_dictionary(MsimMessage *msg, const gchar *name);
-guint msim_msg_get_integer(MsimMessage *msg, const gchar *name);
-gboolean msim_msg_get_binary(MsimMessage *msg, const gchar *name, gchar **binary_data, gsize *binary_length);
+gchar *msim_msg_get_string(const MsimMessage *msg, const gchar *name);
+GList *msim_msg_get_list(const MsimMessage *msg, const gchar *name);
+MsimMessage *msim_msg_get_dictionary(const MsimMessage *msg, const gchar *name);
+guint msim_msg_get_integer(const MsimMessage *msg, const gchar *name);
+gboolean msim_msg_get_binary(const MsimMessage *msg, const gchar *name, gchar **binary_data, gsize *binary_length);
/* Retrieve data by element (MsimMessageElement *), returned from msim_msg_get() */
gchar *msim_msg_get_string_from_element(MsimMessageElement *elem);
============================================================
--- libpurple/protocols/myspace/myspace.c 021969af0e90d6df0ee92bf6503ded981364b1e4
+++ libpurple/protocols/myspace/myspace.c dcda8655ca9db584e56fec75658f605b6eb2858f
@@ -112,7 +112,7 @@ static void
* _uid_before: string, name of field before field to insert, or NULL for end
*/
static void
-msim_postprocess_outgoing_cb(MsimSession *session, MsimMessage *userinfo,
+msim_postprocess_outgoing_cb(MsimSession *session, const MsimMessage *userinfo,
gpointer data)
{
gchar *uid_field_name, *uid_before, *username;
@@ -829,7 +829,7 @@ static void
* Handle mail reply checks.
*/
static void
-msim_check_inbox_cb(MsimSession *session, MsimMessage *reply, gpointer data)
+msim_check_inbox_cb(MsimSession *session, const MsimMessage *reply, gpointer data)
{
MsimMessage *body;
guint old_inbox_status;
@@ -958,7 +958,7 @@ static void
* @param data An MsimMessage * of the contact information. Will be freed.
*/
static void
-msim_add_contact_from_server_cb(MsimSession *session, MsimMessage *user_lookup_info, gpointer data)
+msim_add_contact_from_server_cb(MsimSession *session, const MsimMessage *user_lookup_info, gpointer data)
{
MsimMessage *contact_info, *user_lookup_info_body;
PurpleGroup *group;
@@ -1094,7 +1094,7 @@ static void
* Called when contact list is received from server.
*/
static void
-msim_got_contact_list(MsimSession *session, MsimMessage *reply, gpointer user_data)
+msim_got_contact_list(MsimSession *session, const MsimMessage *reply, gpointer user_data)
{
MsimMessage *body, *body_node;
gchar *msg;
@@ -1767,7 +1767,7 @@ msim_process_reply(MsimSession *session,
if (cb) {
purple_debug_info("msim", "msim_process_reply: calling callback now\n");
/* Clone message, so that the callback 'cb' can use it (needs to free it also). */
- cb(session, msim_msg_clone(msg), data);
+ cb(session, msg, data);
g_hash_table_remove(session->user_lookup_cb, GUINT_TO_POINTER(rid));
g_hash_table_remove(session->user_lookup_cb_data, GUINT_TO_POINTER(rid));
} else {
@@ -1898,7 +1898,7 @@ static void
* @param data MsimMessage *, the message to attach information to.
*/
static void
-msim_incoming_resolved(MsimSession *session, MsimMessage *userinfo,
+msim_incoming_resolved(MsimSession *session, const MsimMessage *userinfo,
gpointer data)
{
gchar *username;
@@ -2340,7 +2340,7 @@ static void
* Callback for msim_get_info(), for when user info is received.
*/
static void
-msim_get_info_cb(MsimSession *session, MsimMessage *user_info_msg,
+msim_get_info_cb(MsimSession *session, const MsimMessage *user_info_msg,
gpointer data)
{
MsimMessage *msg;
@@ -3087,7 +3087,7 @@ static void
* Called when friends have been imported to buddy list on server.
*/
static void
-msim_import_friends_cb(MsimSession *session, MsimMessage *reply, gpointer user_data)
+msim_import_friends_cb(MsimSession *session, const MsimMessage *reply, gpointer user_data)
{
MsimMessage *body;
gchar *completed;
============================================================
--- libpurple/protocols/myspace/user.c d727854b808f4742ad84834b9d82344858467a76
+++ libpurple/protocols/myspace/user.c 729f5bc52b496d0fa54222fc913b19b3bc968ab7
@@ -388,7 +388,7 @@ gboolean
* is a no-op (and returns FALSE).
*/
gboolean
-msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user)
+msim_store_user_info(MsimSession *session, const MsimMessage *msg, MsimUser *user)
{
gchar *username;
MsimMessage *body, *body_node;
@@ -592,9 +592,10 @@ msim_lookup_user(MsimSession *session, c
/**
* Called after username is set.
*/
-static void msim_username_is_set_cb(MsimSession *session, MsimMessage *userinfo, gpointer data)
+static void msim_username_is_set_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
{
- gchar *username, *errmsg;
+ gchar *username;
+ const gchar *errmsg;
MsimMessage *body;
guint rid;
@@ -610,7 +611,8 @@ static void msim_username_is_set_cb(Msim
uid = msim_msg_get_integer(userinfo, "uid");
lid = msim_msg_get_integer(userinfo, "lid");
body = msim_msg_get_dictionary(userinfo, "body");
- errmsg = g_strdup("An error occurred while trying to set the username.\n"
+ /* XXX: Mark for translation */
+ errmsg = ("An error occurred while trying to set the username.\n"
"Please try again, or visit http://editprofile.myspace.com/index.cfm?"
"fuseaction=profile.username to set your username.");
@@ -667,7 +669,6 @@ static void msim_username_is_set_cb(Msim
purple_debug_info("msim","username_is_set Error: Invalid cmd/dsn/lid combination");
purple_connection_error_reason(session->gc, PURPLE_CONNECTION_ERROR_OTHER_ERROR, errmsg);
}
- g_free(errmsg);
}
/**
@@ -751,7 +752,7 @@ static void msim_set_username_confirmed_
* Now we have some real data to tell us the state of their requested username
* \persistr\\cmd\257\dsn\5\uid\204084363\lid\7\rid\367\body\UserName=TheAlbinoRhino1\final\
*/
-static void msim_username_is_available_cb(MsimSession *session, MsimMessage *userinfo, gpointer data)
+static void msim_username_is_available_cb(MsimSession *session, const MsimMessage *userinfo, gpointer data)
{
MsimMessage *msg;
gchar *username;
============================================================
--- libpurple/protocols/myspace/user.h 5c34155c9331a949698f63a0dfbc109940604de1
+++ libpurple/protocols/myspace/user.h 8c7f959c1a55e122cd4ad2299098b430fab1746f
@@ -44,12 +44,12 @@ typedef struct _MsimUser
/* Callback function pointer type for when a user's information is received,
* initiated from a user lookup. */
-typedef void (*MSIM_USER_LOOKUP_CB)(MsimSession *session, MsimMessage *userinfo, gpointer data);
+typedef void (*MSIM_USER_LOOKUP_CB)(MsimSession *session, const MsimMessage *userinfo, gpointer data);
MsimUser *msim_get_user_from_buddy(PurpleBuddy *buddy);
MsimUser *msim_find_user(MsimSession *session, const gchar *username);
void msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full);
-gboolean msim_store_user_info(MsimSession *session, MsimMessage *msg, MsimUser *user);
+gboolean msim_store_user_info(MsimSession *session, const MsimMessage *msg, MsimUser *user);
gboolean msim_is_userid(const gchar *user);
void msim_lookup_user(MsimSession *session, const gchar *user, MSIM_USER_LOOKUP_CB cb, gpointer data);
void msim_set_username_cb(PurpleConnection *gc);
More information about the Commits
mailing list