pidgin/pidgin

The last of the NULL-checks before free()

2015-12-21, Michael McConville
6fd4989b77e4
Parents 5061721fd98f
Children b7ca07c50ef1
The last of the NULL-checks before free()
--- a/finch/gntaccount.c Mon Dec 21 15:00:42 2015 -0500
+++ b/finch/gntaccount.c Mon Dec 21 15:05:58 2015 -0500
@@ -979,8 +979,7 @@
{
g_free(data->username);
- if (data->alias != NULL)
- g_free(data->alias);
+ g_free(data->alias);
g_free(data);
}
--- a/libpurple/ciphers/hmaccipher.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/ciphers/hmaccipher.c Mon Dec 21 15:05:58 2015 -0500
@@ -77,14 +77,10 @@
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
--- a/libpurple/http.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/http.c Mon Dec 21 15:05:58 2015 -0500
@@ -751,8 +751,7 @@
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);
--- a/libpurple/network.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/network.c Mon Dec 21 15:05:58 2015 -0500
@@ -1025,7 +1025,7 @@
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_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_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);
--- a/libpurple/plugins/ssl/ssl-nss.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/plugins/ssl/ssl-nss.c Mon Dec 21 15:05:58 2015 -0500
@@ -682,8 +682,7 @@
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 @@
if (len == 0) {
purple_debug_error("nss/x509",
"Certificate file has no contents!\n");
- if (rawcert)
- g_free(rawcert);
+ g_free(rawcert);
return NULL;
}
--- a/libpurple/protocols/gg/lib/http.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/gg/lib/http.c Mon Dec 21 15:05:58 2015 -0500
@@ -312,10 +312,8 @@
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 @@
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 @@
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 @@
"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);
}
--- a/libpurple/protocols/gg/roster.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/gg/roster.c Mon Dec 21 15:05:58 2015 -0500
@@ -159,8 +159,7 @@
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);
}
--- a/libpurple/protocols/msn/object.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/msn/object.c Mon Dec 21 15:05:58 2015 -0500
@@ -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); \
} \
}
--- a/libpurple/protocols/mxit/client.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/mxit/client.c Mon Dec 21 15:05:58 2015 -0500
@@ -1906,20 +1906,17 @@
/* 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 @@
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 @@
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 );
--- a/libpurple/protocols/mxit/formcmds.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/mxit/formcmds.c Mon Dec 21 15:05:58 2015 -0500
@@ -303,8 +303,7 @@
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);
}
--- a/libpurple/protocols/mxit/markup.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/mxit/markup.c Mon Dec 21 15:05:58 2015 -0500
@@ -258,8 +258,7 @@
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 );
}
}
--- a/libpurple/protocols/mxit/multimx.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/mxit/multimx.c Mon Dec 21 15:05:58 2015 -0500
@@ -164,8 +164,7 @@
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);
--- a/libpurple/protocols/mxit/mxit.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/mxit/mxit.c Mon Dec 21 15:05:58 2015 -0500
@@ -112,8 +112,7 @@
skip:
/* this is not an internal mxit link */
- if ( link )
- g_free( link );
+ g_free(link);
link = NULL;
if ( parts )
@@ -491,12 +490,9 @@
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);
+ g_free(contact->msg);
if (contact->image)
g_object_unref(contact->image);
g_free( contact );
--- a/libpurple/protocols/mxit/roster.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/mxit/roster.c Mon Dec 21 15:05:58 2015 -0500
@@ -481,10 +481,8 @@
// TODO: Download custom mood frame.
/* update status message */
- if ( contact->statusMsg ) {
- g_free( contact->statusMsg );
- contact->statusMsg = NULL;
- }
+ g_free(contact->statusMsg);
+ contact->statusMsg = NULL;
if ( ( statusMsg ) && ( statusMsg[0] != '\0' ) )
contact->statusMsg = g_markup_escape_text( statusMsg, -1 );
@@ -532,8 +530,7 @@
/* avatar has not changed - do nothing */
}
else if ( avatarId[0] != '\0' ) { /* avatar has changed */
- if ( contact->avatarId )
- g_free( contact->avatarId );
+ g_free(contact->avatarId);
contact->avatarId = g_strdup( avatarId );
/* Send request to download new avatar image */
@@ -596,12 +593,9 @@
invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
/* freeup invite object */
- if ( invite->contact->msg )
- g_free( invite->contact->msg );
- if ( invite->contact->statusMsg )
- g_free( invite->contact->statusMsg );
- if ( invite->contact->profile )
- g_free( invite->contact->profile );
+ g_free(invite->contact->msg);
+ g_free(invite->contact->statusMsg);
+ g_free(invite->contact->profile);
if (invite->contact->image)
g_object_unref(invite->contact->image);
g_free( invite->contact );
@@ -627,12 +621,9 @@
invite->session->invites = g_list_remove( invite->session->invites, invite->contact );
/* freeup invite object */
- if ( invite->contact->msg )
- g_free( invite->contact->msg );
- if ( invite->contact->statusMsg )
- g_free( invite->contact->statusMsg );
- if ( invite->contact->profile )
- g_free( invite->contact->profile );
+ g_free(invite->contact->msg);
+ g_free(invite->contact->statusMsg);
+ g_free(invite->contact->profile);
if (invite->contact->image)
g_object_unref(invite->contact->image);
g_free( invite->contact );
--- a/libpurple/protocols/oscar/family_locate.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/oscar/family_locate.c Mon Dec 21 15:05:58 2015 -0500
@@ -549,14 +549,10 @@
* We don't have an away message specified in this user_info
* block, so clear any cached away message now.
*/
- if (cur->away) {
- g_free(cur->away);
- cur->away = NULL;
- }
- if (cur->away_encoding) {
- g_free(cur->away_encoding);
- cur->away_encoding = NULL;
- }
+ g_free(cur->away);
+ cur->away = NULL;
+ g_free(cur->away_encoding);
+ cur->away_encoding = NULL;
cur->away_len = 0;
}
}
--- a/libpurple/protocols/yahoo/yahoochat.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/yahoo/yahoochat.c Mon Dec 21 15:05:58 2015 -0500
@@ -727,8 +727,7 @@
c = purple_conversations_find_chat(gc, YAHOO_CHAT_ID);
if (!who || !c) {
- if (room)
- g_free(room);
+ g_free(room);
/* we still get messages after we part, funny that */
return;
}
@@ -955,10 +954,8 @@
yahoo_packet_send_and_free(pkt, yd);
yd->in_chat = 0;
- if (yd->chat_name) {
- g_free(yd->chat_name);
- yd->chat_name = NULL;
- }
+ g_free(yd->chat_name);
+ yd->chat_name = NULL;
if (purple_conversations_find_chat(gc, YAHOO_CHAT_ID) != NULL)
purple_serv_got_chat_left(gc, YAHOO_CHAT_ID);
--- a/libpurple/protocols/zephyr/zephyr.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/protocols/zephyr/zephyr.c Mon Dec 21 15:05:58 2015 -0500
@@ -2313,10 +2313,8 @@
zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
PurpleStatusPrimitive primitive = purple_status_type_get_primitive(purple_status_get_status_type(status));
- if (zephyr->away) {
- g_free(zephyr->away);
- zephyr->away=NULL;
- }
+ g_free(zephyr->away);
+ zephyr->away = NULL;
if (primitive == PURPLE_STATUS_AWAY) {
zephyr->away = g_strdup(purple_status_get_attr_string(status,"message"));
--- a/libpurple/proxy.c Mon Dec 21 15:00:42 2015 -0500
+++ b/libpurple/proxy.c Mon Dec 21 15:05:58 2015 -0500
@@ -330,18 +330,12 @@
g_free(tmp);
/* Free the old fields */
- if (info.host) {
- g_free(info.host);
- info.host = NULL;
- }
- if (info.username) {
- g_free(info.username);
- info.username = NULL;
- }
- if (info.password) {
- g_free(info.password);
- info.password = NULL;
- }
+ g_free(info.host);
+ info.host = NULL;
+ g_free(info.username);
+ info.username = NULL;
+ g_free(info.password);
+ info.password = NULL;
tmp = purple_gnome_proxy_get_parameter(GNOME_PROXY_USE_SAME_PROXY, gnome_version);
if (!tmp)