changeset 18908:6541b0edee26

Fix some assertion failures, that should really not be assertions. Found by using msimprpl with nullclient.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 12 Aug 2007 18:20:24 +0000
parents 1a11b26fcb11
children c32fcdef2809
files libpurple/protocols/myspace/message.c libpurple/protocols/myspace/myspace.c
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c	Sun Aug 12 18:11:29 2007 +0000
+++ b/libpurple/protocols/myspace/message.c	Sun Aug 12 18:20:24 2007 +0000
@@ -1108,7 +1108,8 @@
  *
  * @param name Name of element.
  *
- * @return gchar * The data as a string. Caller must g_free().
+ * @return gchar * The data as a string, or NULL if not found. 
+ *     Caller must g_free().
  *
  * Note that msim_msg_pack_element_data() is similar, but returns a string
  * for inclusion into a raw protocol string (escaped and everything).
@@ -1120,7 +1121,9 @@
 	MsimMessageElement *elem;
 
 	elem = msim_msg_get(msg, name);
-	g_return_val_if_fail(elem != NULL , NULL);
+	if (!elem) {
+		return NULL;
+	}
 
 	switch (elem->type) {
 		case MSIM_TYPE_INTEGER:
--- a/libpurple/protocols/myspace/myspace.c	Sun Aug 12 18:11:29 2007 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Sun Aug 12 18:20:24 2007 +0000
@@ -1421,7 +1421,10 @@
 	cv = msim_msg_get_string(msg, "cv");
 
 	g_return_val_if_fail(username != NULL, FALSE);
-	g_return_val_if_fail(cv != NULL, FALSE);
+	if (!cv) {
+		/* No client version to record, don't worry about it. */
+		return FALSE;
+	}
 
 	buddy = purple_find_buddy(session->account, username);
 
@@ -2472,7 +2475,11 @@
  * @param session
  * @param msg The user information reply, with any amount of information.
  *
- * The information is saved to the buddy's blist node, which ends up in blist.xml.
+ * The information is saved to the buddy's blist node, which ends up in 
+ * blist.xml. If the function has no buddy information, this function
+ * is a no-op (and returns FALSE).
+ *
+ * TODO: Store ephemeral information in MsimBuddy instead.
  */
 static gboolean 
 msim_store_buddy_info(MsimSession *session, MsimMessage *msg)
@@ -2480,16 +2487,15 @@
 	GHashTable *body;
 	gchar *username, *body_str, *uid;
 	PurpleBuddy *buddy;
-	guint rid;
 
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
  
-	rid = msim_msg_get_integer(msg, "rid");
-	
-	g_return_val_if_fail(rid != 0, FALSE);
-
 	body_str = msim_msg_get_string(msg, "body");
+	if (!body_str) {
+		return FALSE;
+	}
+
 	g_return_val_if_fail(body_str != NULL, FALSE);
 	body = msim_parse_body(body_str);
 	g_free(body_str);