about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-06-08 22:23:00 +0100
committerJames Booth <boothj5@gmail.com>2016-06-08 22:23:00 +0100
commitd79364358a6e222d6e0530a8072c53313e55b044 (patch)
tree27e60fb3f295b7339cd46a7bef8965620c854963
parent4c03ee60667739d709d7f0d66a7c8173d103af24 (diff)
downloadprofani-tty-d79364358a6e222d6e0530a8072c53313e55b044.tar.gz
Fix memory leaks
-rw-r--r--prof.supp19
-rw-r--r--src/chat_session.c7
-rw-r--r--src/otr/otr.c3
3 files changed, 8 insertions, 21 deletions
diff --git a/prof.supp b/prof.supp
index 4f182054..b600993c 100644
--- a/prof.supp
+++ b/prof.supp
@@ -6,25 +6,6 @@
   ...
 }
 
-# libotr
-
-{
-  otrl_init
-  Memcheck:Leak
-  ...
-  fun:otrl_init
-  ...
-}
-
-{
-  otrl_privkey_read
-  Memcheck:Leak
-  ...
-  fun:otrl_privkey_read_FILEp
-  fun:otrl_privkey_read
-  ...
-}
-
 # glib
 
 {
diff --git a/src/chat_session.c b/src/chat_session.c
index 074699fc..25e77a4c 100644
--- a/src/chat_session.c
+++ b/src/chat_session.c
@@ -74,8 +74,11 @@ _chat_session_free(ChatSession *session)
 void
 chat_sessions_init(void)
 {
-    sessions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
-        (GDestroyNotify)_chat_session_free);
+    if (sessions) {
+        g_hash_table_destroy(sessions);
+    }
+
+    sessions = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)_chat_session_free);
 }
 
 void
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 5fc51038..99697411 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -231,6 +231,9 @@ otr_on_connect(ProfAccount *account)
         return;
     }
 
+    if (user_state) {
+        otrl_userstate_free(user_state);
+    }
     user_state = otrl_userstate_create();
 
     gcry_error_t err = 0;