1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Free OTR TLVS

This commit is contained in:
James Booth 2015-08-20 22:23:31 +01:00
parent c18b7f4d67
commit d791e4dd59

View File

@ -708,6 +708,14 @@ otr_encrypt_message(const char * const to, const char * const message)
}
}
static void
_otr_tlv_free(OtrlTLV *tlvs)
{
if (tlvs) {
otrl_tlv_free(tlvs);
}
}
char *
otr_decrypt_message(const char * const from, const char * const message, gboolean *was_decrypted)
{
@ -723,7 +731,6 @@ otr_decrypt_message(const char * const from, const char * const message, gboolea
// common tlv handling
OtrlTLV *tlv = otrl_tlv_find(tlvs, OTRL_TLV_DISCONNECTED);
if (tlv) {
if (context) {
otrl_context_force_plaintext(context);
ui_gone_insecure(from);
@ -732,16 +739,19 @@ otr_decrypt_message(const char * const from, const char * const message, gboolea
// library version specific tlv handling
otrlib_handle_tlvs(user_state, &ops, context, tlvs, smp_initiators);
_otr_tlv_free(tlvs);
return NULL;
// message was decrypted, return to user
} else if (decrypted) {
_otr_tlv_free(tlvs);
*was_decrypted = TRUE;
return decrypted;
// normal non OTR message
} else {
_otr_tlv_free(tlvs);
*was_decrypted = FALSE;
return strdup(message);
}