soc.2009.telepathy: b4c9e534: Added parameter checks to telepathy_cont...

sttwister at gmail.com sttwister at gmail.com
Thu Oct 15 15:55:37 EDT 2009


-----------------------------------------------------------------
Revision: b4c9e5344a9205cbcbd94e89d30c28dce6975e1c
Ancestor: e05953a516e4ebbfa4d862b4d19388de35ad534f
Author: sttwister at gmail.com
Date: 2009-10-14T18:28:38
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/b4c9e5344a9205cbcbd94e89d30c28dce6975e1c

Modified files:
        libpurple/protocols/telepathy/telepathy_contact.c

ChangeLog: 

Added parameter checks to telepathy_contact.c

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy_contact.c	c8190c945e7d9042f33f7d6636e5a120714e8b2f
+++ libpurple/protocols/telepathy/telepathy_contact.c	7bef5e229e628d3b44101d9743f3a0f19db04a80
@@ -70,6 +70,8 @@ remove_contact_cb (TpConnection *connect
 		return;
 	}
 
+	g_return_if_fail(user_data != NULL);
+
 	/* we are going to remove the handle from the stored list */
 	stored_list = g_hash_table_lookup(data->lists, "stored");
 	
@@ -142,8 +144,12 @@ add_contact_to_group_cb (TpConnection *c
 		};
 
 		int i;
-		GArray *arr = g_array_new(0, 0, sizeof(TpHandle));
+		GArray *arr;
 
+		g_return_if_fail(user_data != NULL);
+
+		arr = g_array_new(0, 0, sizeof(TpHandle));
+
 		purple_debug_info("telepathy", "Got handle for adding buddy (%u)!\n",
 				handles[0]);
 
@@ -196,12 +202,17 @@ contact_notify_alias_cb (TpContact *cont
           	         gpointer user_data)
 {
 	PrplTpConnection *data = user_data;
+	const gchar *name;
+	const gchar *alias;
+	PurpleBuddy *buddy;
 
-	const gchar *name = tp_contact_get_identifier(contact);
-	const gchar *alias = tp_contact_get_alias(contact);
+	g_return_if_fail(user_data != NULL);
 
-	PurpleBuddy *buddy = purple_find_buddy(data->acct, tp_contact_get_identifier(contact));
+	name = tp_contact_get_identifier(contact);
+	alias = tp_contact_get_alias(contact);
 
+	buddy = purple_find_buddy(data->acct, tp_contact_get_identifier(contact));
+
 	if (buddy == NULL)
 	{
 		purple_debug_warning("telepathy", "Received TpContact alias notify"
@@ -220,13 +231,19 @@ contact_notify_presence_cb (TpContact *c
 		            gpointer user_data)
 {
 	PrplTpConnection *data = user_data;
+	const gchar *name;
+	const gchar *presence_status;
+	const gchar *presence_message;
+	PurpleBuddy *buddy;
 
-	const gchar *name = tp_contact_get_identifier(contact);
-	const gchar *presence_status = tp_contact_get_presence_status(contact);
-	const gchar *presence_message = tp_contact_get_presence_message(contact);
+	g_return_if_fail(user_data != NULL);
 
-	PurpleBuddy *buddy = purple_find_buddy(data->acct, tp_contact_get_identifier(contact));
+	name = tp_contact_get_identifier(contact);
+	presence_status = tp_contact_get_presence_status(contact);
+	presence_message = tp_contact_get_presence_message(contact);
 
+	buddy = purple_find_buddy(data->acct, tp_contact_get_identifier(contact));
+
 	if (buddy == NULL)
 	{
 		purple_debug_warning("telepathy", "Received TpContact presence notify"
@@ -249,6 +266,8 @@ handle_contacts (PrplTpConnection *conne
 {
 	int i;
 
+	g_return_if_fail(connection_data != NULL);
+
 	purple_debug_info("telepathy", "Contacts ready: %u (%u failed)\n", n_contacts, n_failed);
 
 	for (i = 0; i<n_contacts; ++i)
@@ -258,6 +277,8 @@ handle_contacts (PrplTpConnection *conne
 		guint handle;
 		PrplTpContact *contact_data;
 
+		g_return_if_fail(contact != NULL);
+
 		/* the buddy might already be stored locally */
 		buddy = purple_find_buddy(connection_data->acct, tp_contact_get_identifier(contact));
 
@@ -346,6 +367,8 @@ group_contacts_ready_cb (TpConnection *c
 {
 	PrplTpGroup *data = user_data;
 
+	g_return_if_fail(user_data != NULL);
+
 	if (error != NULL)
 	{
 		purple_debug_error("telepathy", "Contacts ready error: %s\n", error->message);
@@ -354,8 +377,9 @@ group_contacts_ready_cb (TpConnection *c
 	else
 	{
 		PurpleGroup *group;
+		const gchar *group_name;
 
-		const gchar *group_name = tp_channel_get_identifier(data->channel);
+		group_name = tp_channel_get_identifier(data->channel);
 		group = purple_find_group(group_name);
 
 		if (group == NULL)
@@ -379,14 +403,15 @@ contacts_ready_cb (TpConnection *connect
                    gpointer user_data,
                    GObject *weak_object)
 {
-	PrplTpGroup *data = user_data;
-
 	if (error != NULL)
 	{
 		purple_debug_error("telepathy", "Contacts ready error: %s\n", error->message);
 	}
 	else
 	{
+		PrplTpGroup *data = user_data;
+		g_return_if_fail(user_data != NULL);
+
 		handle_contacts(data->connection_data, n_contacts, contacts, n_failed, NULL);
 	}
 }


More information about the Commits mailing list