Fix a memory leak in the afalg engine
[openssl.git] / engines / afalg / e_afalg.c
index d4b4f6bc5885f286523a64bf96deb708673f63a9..90d76020683d852c3db8a36d182532065d340d37 100644 (file)
@@ -539,7 +539,7 @@ static int afalg_cipher_init(EVP_CIPHER_CTX *ctx, const unsigned char *key,
         return 0;
     }
 
-    actx = EVP_CIPHER_CTX_cipher_data(ctx);
+    actx = EVP_CIPHER_CTX_get_cipher_data(ctx);
     if (actx == NULL) {
         ALG_WARN("%s: Cipher data NULL\n", __func__);
         return 0;
@@ -602,7 +602,7 @@ static int afalg_do_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
         return 0;
     }
 
-    actx = (afalg_ctx *) EVP_CIPHER_CTX_cipher_data(ctx);
+    actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx);
     if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) {
         ALG_WARN("%s afalg ctx passed\n",
                  ctx == NULL ? "NULL" : "Uninitialised");
@@ -649,7 +649,7 @@ static int afalg_cipher_cleanup(EVP_CIPHER_CTX *ctx)
         return 0;
     }
 
-    actx = (afalg_ctx *) EVP_CIPHER_CTX_cipher_data(ctx);
+    actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx);
     if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) {
         ALG_WARN("%s afalg ctx passed\n",
                  ctx == NULL ? "NULL" : "Uninitialised");
@@ -844,6 +844,8 @@ static int afalg_finish(ENGINE *e)
 static int afalg_destroy(ENGINE *e)
 {
     ERR_unload_AFALG_strings();
+    EVP_CIPHER_meth_free(_hidden_aes_128_cbc);
+    _hidden_aes_128_cbc = NULL;
     return 1;
 }