/pidgin/main: 96f89e35d24d: Fix various "Dereference before null...

Daniel Atallah datallah at pidgin.im
Mon Feb 18 23:44:40 EST 2013


Changeset: 96f89e35d24d8fcf4a6ca1dd388a71d3a3efed9b
Author:	 Daniel Atallah <datallah at pidgin.im>
Date:	 2013-02-18 23:44 -0500
Branch:	 release-2.x.y
URL: http://hg.pidgin.im/pidgin/main/rev/96f89e35d24d

Description:

Fix various "Dereference before null check" issues

 * Nothing problematic, just unnecessary NULL checks

diffstat:

 libpurple/buddyicon.c                     |  2 +-
 libpurple/certificate.c                   |  4 ++--
 libpurple/log.c                           |  2 +-
 libpurple/plugin.c                        |  7 ++-----
 libpurple/protocols/msn/msn.c             |  2 +-
 libpurple/protocols/oscar/family_locate.c |  2 +-
 libpurple/protocols/silc/ft.c             |  2 --
 libpurple/protocols/yahoo/yahoo_profile.c |  2 +-
 pidgin/gtkconv.c                          |  2 +-
 9 files changed, 10 insertions(+), 15 deletions(-)

diffs (115 lines):

diff --git a/libpurple/buddyicon.c b/libpurple/buddyicon.c
--- a/libpurple/buddyicon.c
+++ b/libpurple/buddyicon.c
@@ -407,7 +407,7 @@ purple_buddy_icon_update(PurpleBuddyIcon
 	icon_to_set = icon->img ? icon : NULL;
 
 	/* Ensure that icon remains valid throughout */
-	if (icon) purple_buddy_icon_ref(icon);
+	purple_buddy_icon_ref(icon);
 
 	buddies = purple_find_buddies(account, username);
 	while (buddies != NULL)
diff --git a/libpurple/certificate.c b/libpurple/certificate.c
--- a/libpurple/certificate.c
+++ b/libpurple/certificate.c
@@ -516,8 +516,8 @@ purple_certificate_pool_mkpath(PurpleCer
 	g_return_val_if_fail(pool->name, NULL);
 
 	/* Escape all the elements for filesystem-friendliness */
-	esc_scheme_name = pool ? g_strdup(purple_escape_filename(pool->scheme_name)) : NULL;
-	esc_name = pool ? g_strdup(purple_escape_filename(pool->name)) : NULL;
+	esc_scheme_name = g_strdup(purple_escape_filename(pool->scheme_name));
+	esc_name = g_strdup(purple_escape_filename(pool->name));
 	esc_id = id ? g_strdup(purple_escape_filename(id)) : NULL;
 
 	path = g_build_filename(purple_user_dir(),
diff --git a/libpurple/log.c b/libpurple/log.c
--- a/libpurple/log.c
+++ b/libpurple/log.c
@@ -1146,7 +1146,7 @@ static void log_get_log_sets_common(GHas
 				}
 
 				/* Determine if this (account, name) combination exists as a buddy. */
-				if (account != NULL && name != NULL && *name != '\0')
+				if (account != NULL && *name != '\0')
 					set->buddy = (purple_find_buddy(account, name) != NULL);
 				else
 					set->buddy = FALSE;
diff --git a/libpurple/plugin.c b/libpurple/plugin.c
--- a/libpurple/plugin.c
+++ b/libpurple/plugin.c
@@ -587,11 +587,8 @@ purple_plugin_load(PurplePlugin *plugin)
 
 	if (plugin->native_plugin)
 	{
-		if (plugin->info != NULL && plugin->info->load != NULL)
-		{
-			if (!plugin->info->load(plugin))
-				return FALSE;
-		}
+		if (plugin->info->load != NULL && !plugin->info->load(plugin))
+			return FALSE;
 	}
 	else {
 		PurplePlugin *loader;
diff --git a/libpurple/protocols/msn/msn.c b/libpurple/protocols/msn/msn.c
--- a/libpurple/protocols/msn/msn.c
+++ b/libpurple/protocols/msn/msn.c
@@ -2764,7 +2764,7 @@ msn_got_photo(PurpleUtilFetchUrlData *ur
 	}
 
 	/* Try to put the photo in there too, if there's one and is readable */
-	if (user_data && url_text && len != 0)
+	if (url_text && len != 0)
 	{
 		if (strstr(url_text, "400 Bad Request")
 			|| strstr(url_text, "403 Forbidden")
diff --git a/libpurple/protocols/oscar/family_locate.c b/libpurple/protocols/oscar/family_locate.c
--- a/libpurple/protocols/oscar/family_locate.c
+++ b/libpurple/protocols/oscar/family_locate.c
@@ -1355,7 +1355,7 @@ aim_locate_setcaps(OscarData *od, guint6
 	aim_snacid_t snacid;
 	GSList *tlvlist = NULL;
 
-	if (!od || !(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)))
+	if (!(conn = flap_connection_findbygroup(od, SNAC_FAMILY_LOCATE)))
 		return -EINVAL;
 
 	aim_tlvlist_add_caps(&tlvlist, 0x0005, caps, mood);
diff --git a/libpurple/protocols/silc/ft.c b/libpurple/protocols/silc/ft.c
--- a/libpurple/protocols/silc/ft.c
+++ b/libpurple/protocols/silc/ft.c
@@ -222,8 +222,6 @@ silcpurple_ftp_request_result(PurpleXfer
 
 	if (purple_xfer_get_status(x) != PURPLE_XFER_STATUS_ACCEPTED)
 		return;
-	if (!xfer)
-		return;
 
 	silc_socket_stream_get_info(silc_packet_stream_get_stream(xfer->sg->conn->stream),
 				    &sock, NULL, NULL, NULL);
diff --git a/libpurple/protocols/yahoo/yahoo_profile.c b/libpurple/protocols/yahoo/yahoo_profile.c
--- a/libpurple/protocols/yahoo/yahoo_profile.c
+++ b/libpurple/protocols/yahoo/yahoo_profile.c
@@ -1035,7 +1035,7 @@ yahoo_got_photo(PurpleUtilFetchUrlData *
 
 #if PHOTO_SUPPORT
 	/* Try to put the photo in there too, if there's one and is readable */
-	if (data && url_text && len != 0) {
+	if (url_text && len != 0) {
 		if (strstr(url_text, "400 Bad Request")
 				|| strstr(url_text, "403 Forbidden")
 				|| strstr(url_text, "404 Not Found")) {
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c
--- a/pidgin/gtkconv.c
+++ b/pidgin/gtkconv.c
@@ -6546,7 +6546,7 @@ gray_stuff_out(PidginConversation *gtkco
 			gtk_widget_show(win->menu.unblock);
 		}
 
-		if ((account == NULL) || purple_find_buddy(account, purple_conversation_get_name(conv)) == NULL) {
+		if (purple_find_buddy(account, purple_conversation_get_name(conv)) == NULL) {
 			gtk_widget_show(win->menu.add);
 			gtk_widget_hide(win->menu.remove);
 		} else {



More information about the Commits mailing list