From 8d05a777adc13f12cc6504120d43b1cc020cfba3 Mon Sep 17 00:00:00 2001 From: Chuan Ma Date: Mon, 24 Mar 2014 23:24:41 -0400 Subject: [PATCH] Fix #66942: openssl_seal() memory leak Fix #66952: memory leak in openssl_open() --- ext/openssl/openssl.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index af9664aec0..4f8f4b7334 100755 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4865,6 +4865,7 @@ PHP_FUNCTION(openssl_seal) if (!EVP_EncryptInit(&ctx,cipher,NULL,NULL)) { RETVAL_FALSE; + EVP_CIPHER_CTX_cleanup(&ctx); goto clean_exit; } @@ -4875,10 +4876,12 @@ PHP_FUNCTION(openssl_seal) #endif /* allocate one byte extra to make room for \0 */ buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx)); + EVP_CIPHER_CTX_cleanup(&ctx); if (!EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) || !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len)) { RETVAL_FALSE; efree(buf); + EVP_CIPHER_CTX_cleanup(&ctx); goto clean_exit; } @@ -4911,6 +4914,7 @@ PHP_FUNCTION(openssl_seal) efree(buf); } RETVAL_LONG(len1 + len2); + EVP_CIPHER_CTX_cleanup(&ctx); clean_exit: for (i=0; i