Mercurial > pidgin.yaz
changeset 17375:7abd1eca3d18
Bug fixes in MsimMessage:
msim_msg_pack_element() now completely ignores fields that begin with '_',
instead of adding an empty string. This eliminates the incorrect empty
spaces between \'s in packed messages.
msim_msg_pack_element() now correctly packs TRUE MSIM_TYPE_BOOLEAN elements,
instead of adding a superfluous slash, that desynchronizes parsing.
msim_msg_get_node() returns NULL if the name passed to it is NULL, instead
of crashing in strcmp(). Similar to how g_malloc(0) == NULL.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Wed, 13 Jun 2007 22:44:26 +0000 |
parents | e9dfd3a5d4b6 |
children | 4cb842e0649c |
files | libpurple/protocols/myspace/message.c |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c Wed Jun 13 21:25:40 2007 +0000 +++ b/libpurple/protocols/myspace/message.c Wed Jun 13 22:44:26 2007 +0000 @@ -336,7 +336,7 @@ /** Insert a new element into a message, before the given element name. * * @param name_before Name of the element to insert the new element before. If - * could not be found, new element will be inserted at end. + * could not be found or NULL, new element will be inserted at end. * * See msim_msg_append() for usage of other parameters, and an important note about return value. */ @@ -539,8 +539,6 @@ /* Exclude elements beginning with '_' from packed protocol messages. */ if (elem->name[0] == '_') { - **items = g_strdup(""); - ++(*items); return; } @@ -563,7 +561,7 @@ if (GPOINTER_TO_UINT(elem->data)) { /* True - leave in, with blank value. */ - string = g_strdup_printf("%s\\\\", elem->name); + string = g_strdup_printf("%s\\", elem->name); } else { /* False - leave out. */ string = g_strdup(""); @@ -727,13 +725,25 @@ } /** Search for and return the node in msg, matching name, or NULL. + * + * @param msg Message to search within. + * @param name Field name to search for. + * + * @return The GList * node for the MsimMessageElement with the given name, or NULL if not found or name is NULL. + * * For internal use - users probably want to use msim_msg_get() to * access the MsimMessageElement *, instead of the GList * container. + * */ static GList *msim_msg_get_node(MsimMessage *msg, gchar *name) { GList *i; + if (!name) + { + return NULL; + } + /* Linear search for the given name. O(n) but n is small. */ for (i = g_list_first(msg); i != NULL; i = g_list_next(i)) {