about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-10-19 08:18:37 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-10-19 08:18:37 +0200
commit2a4d1b8410ca993b55b2e000b65730dbb4c7b234 (patch)
tree142e0b5831fbdb9e7c06a264101583290be4bfaf
parentf190d2c5f233ab0986af11a72094c2666b561c70 (diff)
downloadprofani-tty-2a4d1b8410ca993b55b2e000b65730dbb4c7b234.tar.gz
Free hmac and msgid
-rw-r--r--src/xmpp/connection.c3
-rw-r--r--src/xmpp/message.c7
2 files changed, 7 insertions, 3 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index c2ca16fd..24d6759f 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -469,6 +469,9 @@ connection_create_stanza_id(void)
     GString *signature = g_string_new("");
     g_string_printf(signature, "%s%s", msgid, hmac);
 
+    free(msgid);
+    g_free(hmac);
+
     char *b64 = g_base64_encode((unsigned char*)signature->str, signature->len);
     g_string_free(signature, TRUE);
 
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index cf521237..fb9022dc 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -1165,7 +1165,7 @@ message_is_sent_by_us(ProfMessage *message) {
 
     // we check the </origin-id> for this we calculate a hash into it so we can detect
     // whether this client sent it. See connection_create_stanza_id()
-    if (message->id != NULL) {
+    if (message && message->id != NULL) {
         gsize tmp_len;
         char *tmp = (char*)g_base64_decode(message->id, &tmp_len);
 
@@ -1178,11 +1178,12 @@ message_is_sent_by_us(ProfMessage *message) {
                     (guchar*)prof_identifier, strlen(prof_identifier),
                     msgid, strlen(msgid));
 
-            g_free(msgid);
-
             if (g_strcmp0(&tmp[10], hmac) == 0) {
                 ret = TRUE;
             }
+
+            g_free(msgid);
+            g_free(hmac);
         }
         free(tmp);
     }