mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-25 03:16:20 +00:00
most FREE_SET_NULL replaced with free
FREE_SET_NULL makes extra assignment of NULL for pointers in stack or dynamic memory that is going to be freed. FREE_SET_NULL is useful for pointers that can be used in future.
This commit is contained in:
@@ -301,17 +301,16 @@ static void
|
||||
_caps_destroy(Capabilities *caps)
|
||||
{
|
||||
if (caps != NULL) {
|
||||
FREE_SET_NULL(caps->category);
|
||||
FREE_SET_NULL(caps->type);
|
||||
FREE_SET_NULL(caps->name);
|
||||
FREE_SET_NULL(caps->software);
|
||||
FREE_SET_NULL(caps->software_version);
|
||||
FREE_SET_NULL(caps->os);
|
||||
FREE_SET_NULL(caps->os_version);
|
||||
free(caps->category);
|
||||
free(caps->type);
|
||||
free(caps->name);
|
||||
free(caps->software);
|
||||
free(caps->software_version);
|
||||
free(caps->os);
|
||||
free(caps->os_version);
|
||||
if (caps->features != NULL) {
|
||||
g_slist_free_full(caps->features, free);
|
||||
caps->features = NULL;
|
||||
}
|
||||
FREE_SET_NULL(caps);
|
||||
free(caps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ _unavailable_handler(xmpp_conn_t * const conn,
|
||||
}
|
||||
}
|
||||
|
||||
FREE_SET_NULL(status_str);
|
||||
free(status_str);
|
||||
jid_destroy(my_jid);
|
||||
jid_destroy(from_jid);
|
||||
|
||||
@@ -471,8 +471,8 @@ _available_handler(xmpp_conn_t * const conn,
|
||||
last_activity);
|
||||
}
|
||||
|
||||
FREE_SET_NULL(status_str);
|
||||
FREE_SET_NULL(show_str);
|
||||
free(status_str);
|
||||
free(show_str);
|
||||
jid_destroy(my_jid);
|
||||
jid_destroy(from_jid);
|
||||
|
||||
@@ -556,10 +556,11 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *jid = xmpp_conn_get_jid(conn);
|
||||
char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
||||
Jid *my_jid = jid_create(jid);
|
||||
Jid *from_jid = jid_create(from);
|
||||
if (from_jid == NULL || from_jid->resourcepart == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *room = from_jid->barejid;
|
||||
char *nick = from_jid->resourcepart;
|
||||
@@ -592,7 +593,7 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
// handle presence from room members
|
||||
} else {
|
||||
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
|
||||
char *show_str, *status_str;
|
||||
char *status_str;
|
||||
|
||||
char *caps_key = NULL;
|
||||
if (stanza_contains_caps(stanza)) {
|
||||
@@ -608,12 +609,15 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
// handle nickname change
|
||||
if (stanza_is_room_nick_change(stanza)) {
|
||||
char *new_nick = stanza_get_new_nick(stanza);
|
||||
muc_set_roster_pending_nick_change(room, new_nick, nick);
|
||||
if (new_nick != NULL) {
|
||||
muc_set_roster_pending_nick_change(room, new_nick, nick);
|
||||
free(new_nick);
|
||||
}
|
||||
} else {
|
||||
prof_handle_room_member_offline(room, nick, "offline", status_str);
|
||||
}
|
||||
} else {
|
||||
show_str = stanza_get_show(stanza, "online");
|
||||
char *show_str = stanza_get_show(stanza, "online");
|
||||
if (!muc_get_roster_received(room)) {
|
||||
muc_add_to_roster(room, nick, show_str, status_str, caps_key);
|
||||
} else {
|
||||
@@ -631,13 +635,13 @@ _room_presence_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
}
|
||||
}
|
||||
|
||||
FREE_SET_NULL(show_str);
|
||||
free(show_str);
|
||||
}
|
||||
|
||||
FREE_SET_NULL(status_str);
|
||||
free(status_str);
|
||||
free(caps_key);
|
||||
}
|
||||
|
||||
jid_destroy(my_jid);
|
||||
jid_destroy(from_jid);
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -140,7 +140,7 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
|
||||
xmpp_stanza_set_name(chat_state, state);
|
||||
xmpp_stanza_set_ns(chat_state, STANZA_NS_CHATSTATES);
|
||||
xmpp_stanza_add_child(msg, chat_state);
|
||||
xmpp_stanza_release(chat_state);
|
||||
xmpp_stanza_release(chat_state);
|
||||
}
|
||||
|
||||
return msg;
|
||||
@@ -840,12 +840,11 @@ void
|
||||
stanza_destroy_form(DataForm *form)
|
||||
{
|
||||
if (form != NULL) {
|
||||
FREE_SET_NULL(form->form_type);
|
||||
if (form->fields != NULL) {
|
||||
GSList *curr_field = form->fields;
|
||||
while (curr_field != NULL) {
|
||||
FormField *field = curr_field->data;
|
||||
FREE_SET_NULL(field->var);
|
||||
free(field->var);
|
||||
if ((field->values) != NULL) {
|
||||
g_slist_free_full(field->values, free);
|
||||
}
|
||||
@@ -854,6 +853,7 @@ stanza_destroy_form(DataForm *form)
|
||||
g_slist_free_full(form->fields, free);
|
||||
}
|
||||
|
||||
free(form->form_type);
|
||||
free(form);
|
||||
}
|
||||
}
|
||||
@@ -941,7 +941,7 @@ stanza_attach_caps(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence)
|
||||
xmpp_stanza_add_child(presence, caps);
|
||||
xmpp_stanza_release(caps);
|
||||
xmpp_stanza_release(query);
|
||||
FREE_SET_NULL(sha1);
|
||||
g_free(sha1);
|
||||
}
|
||||
|
||||
const char *
|
||||
|
||||
Reference in New Issue
Block a user