/soc/2013/ankitkv/gobjectification: d736bcb6c5a1: Check for NULL...

Ankit Vani a at nevitus.org
Mon Jul 15 17:40:23 EDT 2013


Changeset: d736bcb6c5a119720442cb62998b30dae21b5775
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-16 03:10 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/d736bcb6c5a1

Description:

Check for NULL value in GBoxed functions

diffstat:

 libpurple/buddyicon.c    |   6 +++++-
 libpurple/connection.c   |   8 +++++++-
 libpurple/conversation.c |  12 +++++++++---
 libpurple/plugin.c       |   6 +++++-
 4 files changed, 26 insertions(+), 6 deletions(-)

diffs (87 lines):

diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -1135,7 +1135,11 @@ void purple_buddy_icon_get_scale_size(Pu
 static PurpleBuddyIcon *
 purple_buddy_icon_copy(PurpleBuddyIcon *icon)
 {
-	PurpleBuddyIcon *icon_copy = g_new(PurpleBuddyIcon, 1);
+	PurpleBuddyIcon *icon_copy;
+
+	g_return_val_if_fail(icon != NULL, NULL);
+
+	icon_copy = g_new(PurpleBuddyIcon, 1);
 	*icon_copy = *icon;
 
 	return icon_copy;
diff --git a/libpurple/connection.c b/libpurple/connection.c
--- a/libpurple/connection.c
+++ b/libpurple/connection.c
@@ -565,7 +565,11 @@ void purple_connection_disable_reconnect
 static PurpleConnectionErrorInfo *
 purple_connection_error_info_copy(PurpleConnectionErrorInfo *err)
 {
-	PurpleConnectionErrorInfo *newerr = g_new(PurpleConnectionErrorInfo, 1);
+	PurpleConnectionErrorInfo *newerr;
+
+	g_return_val_if_fail(err != NULL, NULL);
+
+	newerr = g_new(PurpleConnectionErrorInfo, 1);
 	*newerr = *err;
 	newerr->description = g_strdup(err->description);
 
@@ -575,6 +579,8 @@ purple_connection_error_info_copy(Purple
 static void
 purple_connection_error_info_free(PurpleConnectionErrorInfo *err)
 {
+	g_return_if_fail(err != NULL);
+
 	g_free(err->description);
 	g_free(err);
 }
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -822,10 +822,14 @@ PurpleConversation *purple_conversation_
 static PurpleConversationMessage *
 purple_conversation_message_copy(PurpleConversationMessage *msg)
 {
-	PurpleConversationMessage *newmsg = g_new(PurpleConversationMessage, 1);
+	PurpleConversationMessage *newmsg;
+
+	g_return_val_if_fail(msg != NULL, NULL);
+
+	newmsg  = g_new(PurpleConversationMessage, 1);
 	*newmsg = *msg;
-	newmsg->who = g_strdup(msg->who);
-	newmsg->what = g_strdup(msg->what);
+	newmsg->who   = g_strdup(msg->who);
+	newmsg->what  = g_strdup(msg->what);
 	newmsg->alias = g_strdup(msg->alias);
 
 	return newmsg;
@@ -834,6 +838,8 @@ purple_conversation_message_copy(PurpleC
 static void
 purple_conversation_message_free(PurpleConversationMessage *msg)
 {
+	g_return_if_fail(msg != NULL);
+
 	g_free(msg->who);
 	g_free(msg->what);
 	g_free(msg->alias);
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -1616,7 +1616,11 @@ purple_plugin_action_free(PurplePluginAc
 static PurplePlugin *
 purple_plugin_copy(PurplePlugin *plugin)
 {
-	PurplePlugin *plugin_copy = g_new(PurplePlugin, 1);
+	PurplePlugin *plugin_copy;
+
+	g_return_val_if_fail(plugin != NULL, NULL);
+
+	plugin_copy = g_new(PurplePlugin, 1);
 	*plugin_copy = *plugin;
 
 	return plugin_copy;



More information about the Commits mailing list