--- a/libpurple/protocols/simple/simple.c Fri Oct 25 07:54:39 2019 +0000
+++ b/libpurple/protocols/simple/simple.c Fri Oct 25 05:11:46 2019 -0400
@@ -201,9 +201,9 @@
-static void watcher_remove(struct simple_account_data *sip, const gchar *name) {
- struct simple_watcher *watcher = watcher_find(sip, name);
- sip->watcher = g_slist_remove(sip->watcher, watcher);
+watcher_destroy(struct simple_watcher *watcher) g_free(watcher->dialog.callid);
g_free(watcher->dialog.ourtag);
@@ -218,22 +218,22 @@
-static void connection_remove(struct simple_account_data *sip, int fd) {
- struct sip_connection *conn = connection_find(sip, fd);
- sip->openconns = g_slist_remove(sip->openconns, conn);
- if(conn->inputhandler) purple_input_remove(conn->inputhandler);
+connection_destroy(struct sip_connection *conn) + if (conn->inputhandler) { + purple_input_remove(conn->inputhandler); + g_clear_pointer(&conn->inbuf, g_free); -static void connection_free_all(struct simple_account_data *sip) {
- struct sip_connection *ret = NULL;
- GSList *entry = sip->openconns;
- connection_remove(sip, ret->fd);
- entry = sip->openconns;
+connection_remove(struct simple_account_data *sip, int fd) + struct sip_connection *conn = connection_find(sip, fd); + sip->openconns = g_slist_remove(sip->openconns, conn); + connection_destroy(conn); static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message)
@@ -654,9 +654,12 @@
g_string_free(outstr, TRUE);
-static void transactions_remove(struct simple_account_data *sip, struct transaction *trans) {
- if(trans->msg) sipmsg_free(trans->msg);
- sip->transactions = g_slist_remove(sip->transactions, trans);
+transactions_destroy(struct transaction *trans) + sipmsg_free(trans->msg); @@ -1056,12 +1059,13 @@
/* remove a timed out suscriber */
+ GSList *next = tmp->next; struct simple_watcher *watcher = tmp->data;
if(watcher->expire < curtime) {
- watcher_remove(sip, watcher->name);
+ sip->watcher = g_slist_delete_link(sip->watcher, tmp); + watcher_destroy(watcher); - if(tmp) tmp = tmp->next;
@@ -1652,7 +1656,9 @@
/* call the callback to process response*/
(trans->callback)(sip, msg, trans);
- transactions_remove(sip, trans);
+ g_slist_remove(sip->transactions, trans); + transactions_destroy(trans); @@ -2086,7 +2092,7 @@
- connection_free_all(sip);
+ g_slist_free_full(sip->openconns, (GDestroyNotify)connection_destroy); purple_input_remove(sip->listenpa);
@@ -2124,8 +2130,7 @@
g_hash_table_destroy(sip->buddies);
- while (sip->transactions)
- transactions_remove(sip, sip->transactions->data);
+ g_slist_free_full(sip->transactions, (GDestroyNotify)transactions_destroy); g_free(sip->publish_etag);
g_object_unref(G_OBJECT(sip->txbuf));
--- a/libpurple/protocols/simple/sipmsg.c Fri Oct 25 07:54:39 2019 +0000
+++ b/libpurple/protocols/simple/sipmsg.c Fri Oct 25 05:11:46 2019 -0400
@@ -177,15 +177,16 @@
msg->headers = g_slist_append(msg->headers, element);
+sipmsg_free_header(struct siphdrelement *elem) void sipmsg_free(struct sipmsg *msg) {
- struct siphdrelement *elem;
- elem = msg->headers->data;
- msg->headers = g_slist_remove(msg->headers,elem);
+ g_slist_free_full(msg->headers, (GDestroyNotify)sipmsg_free_header); @@ -197,9 +198,7 @@
struct siphdrelement *elem = tmp->data;
msg->headers = g_slist_delete_link(msg->headers, tmp);
+ sipmsg_free_header(elem);