From 06dc31181752c3e59b4c5b58b24f023640898564 Mon Sep 17 00:00:00 2001 From: Thurston Hou Yeen Dang Date: Mon, 18 Jul 2016 14:16:37 -0700 Subject: [PATCH] Call EVP_CIPHER_CTX_cleanup to avoid leaking memory that was allocated in EVP_DecryptInit_ex Also add matching cleanup to EVP_EncryptInit_ex for symmetry (though I'm not convinced it actually leaks memory) Change-Id: Icf72dd9e0295d8b6ea55909266a43e684b16420f --- cryptfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cryptfs.c b/cryptfs.c index 0334bbd..6dd56cb 100644 --- a/cryptfs.c +++ b/cryptfs.c @@ -1409,6 +1409,8 @@ static int encrypt_master_key(const char *passwd, const unsigned char *salt, SLOGE("encrypt_master_key: crypto_scrypt failed"); } + EVP_CIPHER_CTX_cleanup(&e_ctx); + return 0; } @@ -1458,6 +1460,8 @@ static int decrypt_master_key_aux(const char *passwd, unsigned char *salt, } } + EVP_CIPHER_CTX_cleanup(&d_ctx); + return 0; }