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 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); }