Fix various "Dereference before null check" issues release-2.x.y

Mon, 18 Feb 2013 23:44:29 -0500

author
Daniel Atallah <datallah@pidgin.im>
date
Mon, 18 Feb 2013 23:44:29 -0500
branch
release-2.x.y
changeset 33769
96f89e35d24d
parent 33767
624cf59658dc
child 33770
6625cbf09e08

Fix various "Dereference before null check" issues

* Nothing problematic, just unnecessary NULL checks

libpurple/buddyicon.c file | annotate | diff | comparison | revisions
libpurple/certificate.c file | annotate | diff | comparison | revisions
libpurple/log.c file | annotate | diff | comparison | revisions
libpurple/plugin.c file | annotate | diff | comparison | revisions
libpurple/protocols/msn/msn.c file | annotate | diff | comparison | revisions
libpurple/protocols/oscar/family_locate.c file | annotate | diff | comparison | revisions
libpurple/protocols/silc/ft.c file | annotate | diff | comparison | revisions
libpurple/protocols/yahoo/yahoo_profile.c file | annotate | diff | comparison | revisions
pidgin/gtkconv.c file | annotate | diff | comparison | revisions
--- a/libpurple/buddyicon.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/buddyicon.c	Mon Feb 18 23:44:29 2013 -0500
@@ -407,7 +407,7 @@
 	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)
--- a/libpurple/certificate.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/certificate.c	Mon Feb 18 23:44:29 2013 -0500
@@ -516,8 +516,8 @@
 	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(),
--- a/libpurple/log.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/log.c	Mon Feb 18 23:44:29 2013 -0500
@@ -1146,7 +1146,7 @@
 				}
 
 				/* 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;
--- a/libpurple/plugin.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/plugin.c	Mon Feb 18 23:44:29 2013 -0500
@@ -587,11 +587,8 @@
 
 	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;
--- a/libpurple/protocols/msn/msn.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/protocols/msn/msn.c	Mon Feb 18 23:44:29 2013 -0500
@@ -2764,7 +2764,7 @@
 	}
 
 	/* 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")
--- a/libpurple/protocols/oscar/family_locate.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/protocols/oscar/family_locate.c	Mon Feb 18 23:44:29 2013 -0500
@@ -1355,7 +1355,7 @@
 	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);
--- a/libpurple/protocols/silc/ft.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/protocols/silc/ft.c	Mon Feb 18 23:44:29 2013 -0500
@@ -222,8 +222,6 @@
 
 	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);
--- a/libpurple/protocols/yahoo/yahoo_profile.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/libpurple/protocols/yahoo/yahoo_profile.c	Mon Feb 18 23:44:29 2013 -0500
@@ -1035,7 +1035,7 @@
 
 #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")) {
--- a/pidgin/gtkconv.c	Mon Feb 18 23:23:12 2013 -0500
+++ b/pidgin/gtkconv.c	Mon Feb 18 23:44:29 2013 -0500
@@ -6546,7 +6546,7 @@
 			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 {

mercurial