Skip to content

Commit

Permalink
axc: fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
fbrausse committed Jul 28, 2019
1 parent 2cafb15 commit 960429c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/axc.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ void axc_bundle_destroy(axc_bundle * bundle_p) {
axc_buf_free(bundle_p->signed_pre_key_public_serialized_p);
axc_buf_free(bundle_p->signed_pre_key_signature_p);
axc_buf_free(bundle_p->identity_key_public_serialized_p);
free(bundle_p);
}
}

Expand Down Expand Up @@ -414,6 +415,7 @@ void axc_context_destroy_all(axc_context * ctx_p) {
axc_mutexes_destroy(ctx_p->mutexes_p);

free(ctx_p->db_filename);
free(ctx_p);
}
}

Expand Down Expand Up @@ -1111,6 +1113,10 @@ int axc_pre_key_message_process(axc_buf * pre_key_msg_serialized_p, axc_address


do {
if (key_l_p) {
signal_protocol_key_helper_key_list_free(key_l_p);
key_l_p = NULL;
}
ret_val = signal_protocol_key_helper_generate_pre_keys(&key_l_p, new_id, 1, ctx_p->axolotl_global_context_p);
if (ret_val) {
err_msg = "failed to generate a new key";
Expand Down Expand Up @@ -1158,7 +1164,7 @@ int axc_pre_key_message_process(axc_buf * pre_key_msg_serialized_p, axc_address

SIGNAL_UNREF(pre_key_msg_p);
SIGNAL_UNREF(session_record_p);
SIGNAL_UNREF(session_cipher_p);
session_cipher_free(session_cipher_p);
session_builder_free(session_builder_p);
signal_protocol_key_helper_key_list_free(key_l_p);

Expand Down
1 change: 1 addition & 0 deletions src/axc_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ int aes_encrypt(signal_buffer ** output_pp,
}
}

free(pt_p);
free(out_p);
gcry_cipher_close(cipher_hd);

Expand Down
3 changes: 2 additions & 1 deletion src/axc_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,15 +757,16 @@ int axc_db_pre_key_get_list(size_t amount, axc_context * axc_ctx_p, axc_buf_list
}

*list_head_pp = axc_buf_list_item_get_next(head_p);
axc_buf_list_item_set_next(head_p, NULL);
ret_val = 0;

cleanup:
if (ret_val) {
axc_buf_free(serialized_keypair_data_p);
SIGNAL_UNREF(pre_key_p);
axc_buf_free(pre_key_public_serialized_p);
axc_buf_list_free(head_p);
}
axc_buf_list_free(head_p);

db_conn_cleanup(db_p, pstmt_p, err_msg, __func__, axc_ctx_p);
return ret_val;
Expand Down

0 comments on commit 960429c

Please sign in to comment.