From: Chuan Ma Date: Tue, 25 Mar 2014 03:24:41 +0000 (-0400) Subject: Fix #66942: openssl_seal() memory leak X-Git-Tag: php-5.6.0beta2~1^2~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f413a77b3ddca0abcf4552db070618af635c4bc1;p=php Fix #66942: openssl_seal() memory leak Fix #66952: memory leak in openssl_open() --- diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 1781cc1776..8badbf7e00 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