about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2019-07-10 12:27:28 +0200
committerPaul Fariello <paul@fariello.eu>2019-07-10 17:32:23 +0200
commitb110da9a923c64be7ba33cac3212596c118ccd0d (patch)
treefa5b35dfa715b8d469139a9f695dcbf81b938953 /src
parenteb14ae5f03f8dcc013956b9f3367c6c90700c3ff (diff)
downloadprofani-tty-b110da9a923c64be7ba33cac3212596c118ccd0d.tar.gz
Fix various OMEMO memleaks
Diffstat (limited to 'src')
-rw-r--r--src/omemo/omemo.c4
-rw-r--r--src/omemo/store.c11
-rw-r--r--src/xmpp/connection.c6
-rw-r--r--src/xmpp/stanza.c9
4 files changed, 25 insertions, 5 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index 02107432..f82ad164 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -1363,14 +1363,14 @@ omemo_automatic_start(const char *const recipient)
             } else if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
                 result = FALSE;
             } else {
-                return FALSE;
+                result = FALSE;
             }
             break;
         case PROF_OMEMOPOLICY_ALWAYS:
             if (g_list_find_custom(account->omemo_disabled, recipient, (GCompareFunc)g_strcmp0)) {
                 result = FALSE;
             } else {
-                return TRUE;
+                result = TRUE;
             }
             break;
     }
diff --git a/src/omemo/store.c b/src/omemo/store.c
index 3e44be43..2efcae4c 100644
--- a/src/omemo/store.c
+++ b/src/omemo/store.c
@@ -38,10 +38,12 @@
 #include "omemo/omemo.h"
 #include "omemo/store.h"
 
+static void _g_hash_table_free(GHashTable *hash_table);
+
 GHashTable *
 session_store_new(void)
 {
-    return g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+    return g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_g_hash_table_free);
 }
 
 GHashTable *
@@ -441,3 +443,10 @@ load_sender_key(signal_buffer **record, signal_buffer **user_record,
 {
     return SG_SUCCESS;
 }
+
+static void
+_g_hash_table_free(GHashTable *hash_table)
+{
+    g_hash_table_remove_all(hash_table);
+    g_hash_table_unref(hash_table);
+}
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 62b56666..46ae1ed8 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -290,6 +290,7 @@ connection_send_stanza(const char *const stanza)
 gboolean
 connection_supports(const char *const feature)
 {
+    gboolean ret = FALSE;
     GList *jids = g_hash_table_get_keys(conn.features_by_jid);
 
     GList *curr = jids;
@@ -297,7 +298,8 @@ connection_supports(const char *const feature)
         char *jid = curr->data;
         GHashTable *features = g_hash_table_lookup(conn.features_by_jid, jid);
         if (features && g_hash_table_lookup(features, feature)) {
-            return TRUE;
+            ret = TRUE;
+            break;
         }
 
         curr = g_list_next(curr);
@@ -305,7 +307,7 @@ connection_supports(const char *const feature)
 
     g_list_free(jids);
 
-    return FALSE;
+    return ret;
 }
 
 char*
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index affb6ff4..2801ab53 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -1869,6 +1869,15 @@ stanza_attach_publish_options(xmpp_ctx_t *const ctx, xmpp_stanza_t *const iq, co
 
     xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(iq, STANZA_NS_PUBSUB);
     xmpp_stanza_add_child(pubsub, publish_options);
+
+    xmpp_stanza_release(access_model_value_text);
+    xmpp_stanza_release(access_model_value);
+    xmpp_stanza_release(access_model);
+    xmpp_stanza_release(form_type_value_text);
+    xmpp_stanza_release(form_type_value);
+    xmpp_stanza_release(form_type);
+    xmpp_stanza_release(x);
+    xmpp_stanza_release(publish_options);
 }
 
 void