diff libpurple/protocols/myspace/message.c @ 17976:b2d81d13f015

Be more careful about null strings in %s format specifier in debug messages.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sun, 05 Aug 2007 03:02:17 +0000
parents acff371d7908
children e0cac5db762b
line wrap: on
line diff
--- a/libpurple/protocols/myspace/message.c	Sun Aug 05 02:25:59 2007 +0000
+++ b/libpurple/protocols/myspace/message.c	Sun Aug 05 03:02:17 2007 +0000
@@ -696,6 +696,8 @@
 static gchar *
 msim_msg_pack_element_data(MsimMessageElement *elem)
 {
+    g_return_val_if_fail(elem != NULL, NULL);
+
 	switch (elem->type)
 	{
 		case MSIM_TYPE_INTEGER:
@@ -746,7 +748,9 @@
             }
 
 		default:
-			purple_debug_info("msim", "field %s, unknown type %d\n", elem->name, elem->type);
+			purple_debug_info("msim", "field %s, unknown type %d\n", 
+                    elem->name ? elem->name : "(NULL)", 
+                    elem->type);
 			return NULL;
 	}
 }
@@ -1005,7 +1009,8 @@
         }
 
 #ifdef MSIM_DEBUG_PARSE
-        purple_debug_info("msim", "-- %s: %s\n", key, value);
+        purple_debug_info("msim", "-- %s: %s\n", key ? key : "(NULL)", 
+                value ? value : "(NULL)");
 #endif
 
         /* XXX: This overwrites duplicates. */
@@ -1095,8 +1100,7 @@
 	MsimMessageElement *elem;
 
 	elem = msim_msg_get(msg, name);
-	if (!elem)
-		return NULL;
+    g_return_val_if_fail(elem != NULL , NULL);
 
 	switch (elem->type)
 	{
@@ -1114,7 +1118,7 @@
 
 		default:
 			purple_debug_info("msim", "msim_msg_get_string: type %d unknown, name %s\n",
-					elem->type, name);
+					elem->type, name ? name : "(NULL)");
 			return NULL;
 	}
 }
@@ -1139,7 +1143,7 @@
 
         default:
             purple_debug_info("msim_msg_get_list", "type %d unknown, name %s\n",
-                    elem->type, name);
+                    elem->type, name ? name : "(NULL)");
             return NULL;
     }
 }
@@ -1172,7 +1176,7 @@
 
         default:
             purple_debug_info("msim_msg_get_dictionary", "type %d unknown, name %s\n",
-                    elem->type, name);
+                    elem->type, name ? name : "(NULL)");
             return NULL;
     }
 }
@@ -1227,6 +1231,8 @@
 	MsimMessageElement *elem;
 
 	elem = msim_msg_get(msg, name);
+    if (!elem)
+        return FALSE;
 
 	switch (elem->type)
 	{
@@ -1277,7 +1283,7 @@
 
 		default:
 			purple_debug_info("msim", "msim_msg_get_binary: unhandled type %d for key %s\n",
-					elem->type, name);
+					elem->type, name ? name : "(NULL)");
 			return FALSE;
 	}
 }