/pidgin/main: 6fd4989b77e4: The last of the NULL-checks before f...

Michael McConville mmcco at mykolab.com
Mon Dec 21 15:06:04 EST 2015


Changeset: 6fd4989b77e4d6aa34718214738e54286170f11b
Author:	 Michael McConville <mmcco at mykolab.com>
Date:	 2015-12-21 15:05 -0500
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/6fd4989b77e4

Description:

The last of the NULL-checks before free()

diffstat:

 finch/gntaccount.c                        |   3 +--
 libpurple/ciphers/hmaccipher.c            |  12 ++++--------
 libpurple/http.c                          |   3 +--
 libpurple/network.c                       |   7 +++----
 libpurple/plugins/ssl/ssl-nss.c           |   6 ++----
 libpurple/protocols/gg/lib/http.c         |  24 ++++++++----------------
 libpurple/protocols/gg/roster.c           |   3 +--
 libpurple/protocols/msn/object.c          |   3 +--
 libpurple/protocols/mxit/client.c         |  21 +++++++--------------
 libpurple/protocols/mxit/formcmds.c       |   3 +--
 libpurple/protocols/mxit/markup.c         |   3 +--
 libpurple/protocols/mxit/multimx.c        |   3 +--
 libpurple/protocols/mxit/mxit.c           |  12 ++++--------
 libpurple/protocols/mxit/roster.c         |  27 +++++++++------------------
 libpurple/protocols/oscar/family_locate.c |  12 ++++--------
 libpurple/protocols/yahoo/yahoochat.c     |   9 +++------
 libpurple/protocols/zephyr/zephyr.c       |   6 ++----
 libpurple/proxy.c                         |  18 ++++++------------
 18 files changed, 59 insertions(+), 116 deletions(-)

diffs (truncated from 454 to 300 lines):

diff --git a/finch/gntaccount.c b/finch/gntaccount.c
--- a/finch/gntaccount.c
+++ b/finch/gntaccount.c
@@ -979,8 +979,7 @@ free_add_user_data(AddUserData *data)
 {
 	g_free(data->username);
 
-	if (data->alias != NULL)
-		g_free(data->alias);
+	g_free(data->alias);
 
 	g_free(data);
 }
diff --git a/libpurple/ciphers/hmaccipher.c b/libpurple/ciphers/hmaccipher.c
--- a/libpurple/ciphers/hmaccipher.c
+++ b/libpurple/ciphers/hmaccipher.c
@@ -77,14 +77,10 @@ purple_hmac_cipher_reset(PurpleCipher *c
 	if(PURPLE_IS_HASH(priv->hash))
 		purple_hash_reset(priv->hash);
 
-	if(priv->ipad) {
-		g_free(priv->ipad);
-		priv->ipad = NULL;
-	}
-	if(priv->opad) {
-		g_free(priv->opad);
-		priv->opad = NULL;
-	}
+	g_free(priv->ipad);
+	priv->ipad = NULL;
+	g_free(priv->opad);
+	priv->opad = NULL;
 }
 
 static void
diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -751,8 +751,7 @@ static void _purple_http_gen_headers(Pur
 		request_url,
 		req->http11 ? "1.1" : "1.0");
 
-	if (tmp_url)
-		g_free(tmp_url);
+	g_free(tmp_url);
 
 	if (!purple_http_headers_get(hdrs, "host"))
 		g_string_append_printf(h, "Host: %s\r\n", url->host);
diff --git a/libpurple/network.c b/libpurple/network.c
--- a/libpurple/network.c
+++ b/libpurple/network.c
@@ -1025,7 +1025,7 @@ purple_network_set_stun_server(const gch
 			purple_debug_info("network",
 				"network is unavailable, don't try to update STUN IP");
 		}
-	} else if (stun_ip) {
+	} else {
 		g_free(stun_ip);
 		stun_ip = NULL;
 	}
@@ -1044,7 +1044,7 @@ purple_network_set_turn_server(const gch
 			purple_debug_info("network",
 				"network is unavailable, don't try to update TURN IP");
 		}
-	} else if (turn_ip) {
+	} else {
 		g_free(turn_ip);
 		turn_ip = NULL;
 	}
@@ -1314,8 +1314,7 @@ purple_network_uninit(void)
 	purple_signal_unregister(purple_network_get_handle(),
 							 "network-configuration-changed");
 
-	if (stun_ip)
-		g_free(stun_ip);
+	g_free(stun_ip);
 
 	g_hash_table_destroy(upnp_port_mappings);
 	g_hash_table_destroy(nat_pmp_port_mappings);
diff --git a/libpurple/plugins/ssl/ssl-nss.c b/libpurple/plugins/ssl/ssl-nss.c
--- a/libpurple/plugins/ssl/ssl-nss.c
+++ b/libpurple/plugins/ssl/ssl-nss.c
@@ -682,8 +682,7 @@ x509_import_from_file(const gchar *filen
 	if (len == 0) {
 		purple_debug_error("nss/x509",
 				"Certificate file has no contents!\n");
-		if (rawcert)
-			g_free(rawcert);
+		g_free(rawcert);
 		return NULL;
 	}
 
@@ -731,8 +730,7 @@ x509_importcerts_from_file(const gchar *
 	if (len == 0) {
 		purple_debug_error("nss/x509",
 				"Certificate file has no contents!\n");
-		if (rawcert)
-			g_free(rawcert);
+		g_free(rawcert);
 		return NULL;
 	}
 
diff --git a/libpurple/protocols/gg/lib/http.c b/libpurple/protocols/gg/lib/http.c
--- a/libpurple/protocols/gg/lib/http.c
+++ b/libpurple/protocols/gg/lib/http.c
@@ -312,10 +312,8 @@ int gg_http_watch_fd(struct gg_http *h)
 
 		if (res == -1 && errno != EINTR && errno != EAGAIN) {
 			gg_debug(GG_DEBUG_MISC, "=> http, reading header failed (errno=%d)\n", errno);
-			if (h->header) {
-				free(h->header);
-				h->header = NULL;
-			}
+			free(h->header);
+			h->header = NULL;
 			gg_http_error(GG_ERROR_READING);
 		}
 
@@ -328,10 +326,8 @@ int gg_http_watch_fd(struct gg_http *h)
 
 		if (res == 0) {
 			gg_debug(GG_DEBUG_MISC, "=> http, connection reset by peer\n");
-			if (h->header) {
-				free(h->header);
-				h->header = NULL;
-			}
+			free(h->header);
+			h->header = NULL;
 			gg_http_error(GG_ERROR_READING);
 		}
 
@@ -447,10 +443,8 @@ int gg_http_watch_fd(struct gg_http *h)
 
 		if (res == -1 && errno != EINTR && errno != EAGAIN) {
 			gg_debug(GG_DEBUG_MISC, "=> http, reading body failed (errno=%d)\n", errno);
-			if (h->body) {
-				free(h->body);
-				h->body = NULL;
-			}
+			free(h->body);
+			h->body = NULL;
 			gg_http_error(GG_ERROR_READING);
 		}
 
@@ -472,10 +466,8 @@ int gg_http_watch_fd(struct gg_http *h)
 					"connection closed while reading "
 					"(have %d, need %d)\n",
 					h->body_done, h->body_size);
-				if (h->body) {
-					free(h->body);
-					h->body = NULL;
-				}
+				free(h->body);
+				h->body = NULL;
 				gg_http_error(GG_ERROR_READING);
 			}
 
diff --git a/libpurple/protocols/gg/roster.c b/libpurple/protocols/gg/roster.c
--- a/libpurple/protocols/gg/roster.c
+++ b/libpurple/protocols/gg/roster.c
@@ -159,8 +159,7 @@ static void ggp_roster_content_free(ggp_
 		g_hash_table_destroy(content->group_ids);
 	if (content->group_names)
 		g_hash_table_destroy(content->group_names);
-	if (content->bots_group_id)
-		g_free(content->bots_group_id);
+	g_free(content->bots_group_id);
 	g_free(content);
 }
 
diff --git a/libpurple/protocols/msn/object.c b/libpurple/protocols/msn/object.c
--- a/libpurple/protocols/msn/object.c
+++ b/libpurple/protocols/msn/object.c
@@ -37,8 +37,7 @@
 		c = strchr(tag, '"'); \
 		if (c != NULL) \
 		{ \
-			if (obj->field != NULL) \
-				g_free(obj->field); \
+			g_free(obj->field); \
 			obj->field = g_strndup(tag, c - tag); \
 		} \
 	}
diff --git a/libpurple/protocols/mxit/client.c b/libpurple/protocols/mxit/client.c
--- a/libpurple/protocols/mxit/client.c
+++ b/libpurple/protocols/mxit/client.c
@@ -1906,20 +1906,17 @@ static void mxit_parse_cmd_extprofile( s
 			/* this is an invite, so update its profile info */
 			if ( ( statusMsg ) && ( *statusMsg ) ) {
 				/* update the status message */
-				if ( contact->statusMsg )
-					g_free( contact->statusMsg );
+				g_free(contact->statusMsg);
 				contact->statusMsg = strdup( statusMsg );
 			}
 			else
 				contact->statusMsg = NULL;
-			if ( contact->profile )
-				g_free( contact->profile );
+			g_free(contact->profile);
 			contact->profile = profile;
 			if ( ( avatarId ) && ( *avatarId ) ) {
 				/* avatar must be requested for this invite before we can display it */
 				mxit_get_avatar( session, mxitId, avatarId );
-				if ( contact->avatarId )
-					g_free( contact->avatarId );
+				g_free(contact->avatarId);
 				contact->avatarId = strdup( avatarId );
 			}
 			else {
@@ -1941,8 +1938,7 @@ static void mxit_parse_cmd_extprofile( s
 				if ( buddy ) {
 					contact = purple_buddy_get_protocol_data( buddy );
 					if ( contact ) {
-						if ( contact->statusMsg )
-							g_free( contact->statusMsg );
+						g_free(contact->statusMsg);
 						contact->statusMsg = strdup( statusMsg );
 					}
 				}
@@ -2926,12 +2922,9 @@ void mxit_close_connection( struct MXitS
 
 		session->invites = g_list_remove( session->invites, contact );
 
-		if ( contact->msg )
-			g_free( contact->msg );
-		if ( contact->statusMsg )
-			g_free( contact->statusMsg );
-		if ( contact->profile )
-			g_free( contact->profile );
+		g_free(contact->msg);
+		g_free(contact->statusMsg);
+		g_free(contact->profile);
 		if (contact->image)
 			g_object_unref(contact->image);
 		g_free( contact );
diff --git a/libpurple/protocols/mxit/formcmds.c b/libpurple/protocols/mxit/formcmds.c
--- a/libpurple/protocols/mxit/formcmds.c
+++ b/libpurple/protocols/mxit/formcmds.c
@@ -303,8 +303,7 @@ static void command_platformreq(GHashTab
 		g_string_append_printf(msg, "<a href=\"%s\">%s</a>", purple_url_decode(dest), (text) ? text : _( "Download" ));		/* add link to display message */
 	}
 
-	if (text)
-		g_free(text);
+	g_free(text);
 }
 
 
diff --git a/libpurple/protocols/mxit/markup.c b/libpurple/protocols/mxit/markup.c
--- a/libpurple/protocols/mxit/markup.c
+++ b/libpurple/protocols/mxit/markup.c
@@ -258,8 +258,7 @@ static void free_markupdata( struct RXMs
 	if ( mx ) {
 		if ( mx->msg )
 			g_string_free( mx->msg, TRUE );
-		if ( mx->from )
-			g_free( mx->from );
+		g_free(mx->from);
 		g_free( mx );
 	}
 }
diff --git a/libpurple/protocols/mxit/multimx.c b/libpurple/protocols/mxit/multimx.c
--- a/libpurple/protocols/mxit/multimx.c
+++ b/libpurple/protocols/mxit/multimx.c
@@ -164,8 +164,7 @@ static void room_remove(struct MXitSessi
 	session->rooms = g_list_remove(session->rooms, multimx);
 
 	/* free nickname */
-	if (multimx->nickname)
-		g_free(multimx->nickname);
+	g_free(multimx->nickname);
 
 	/* Deallocate it */
 	g_free (multimx);
diff --git a/libpurple/protocols/mxit/mxit.c b/libpurple/protocols/mxit/mxit.c
--- a/libpurple/protocols/mxit/mxit.c
+++ b/libpurple/protocols/mxit/mxit.c
@@ -112,8 +112,7 @@ static void* mxit_link_click( const char
 skip:
 	/* this is not an internal mxit link */
 
-	if ( link )
-		g_free( link );
+	g_free(link);
 	link = NULL;
 
 	if ( parts )
@@ -491,12 +490,9 @@ static void mxit_free_buddy( PurpleBuddy
 
 	contact = purple_buddy_get_protocol_data( buddy );
 	if ( contact ) {
-		if ( contact->statusMsg )
-			g_free( contact->statusMsg );
-		if ( contact->avatarId )
-			g_free( contact->avatarId );
-		if ( contact->msg )
-			g_free( contact->msg );
+		g_free(contact->statusMsg);
+		g_free(contact->avatarId);



More information about the Commits mailing list