summaryrefslogtreecommitdiff
path: root/ext/mcrypt
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2010-06-02 15:27:38 +0000
committerPierre Joye <pajoye@php.net>2010-06-02 15:27:38 +0000
commitb03678348c43797f74a8097933a958cc300609ae (patch)
tree51faafc7da5782edfc5dfe6a7621c2eba0bfe6f0 /ext/mcrypt
parent99da695ec90890c3de9d4ae17c2e26133ab9bdc4 (diff)
downloadphp-git-b03678348c43797f74a8097933a958cc300609ae.tar.gz
- fix leak on error in mcrypt_create_iv on windows
Diffstat (limited to 'ext/mcrypt')
-rw-r--r--ext/mcrypt/mcrypt.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c
index 23c8eeb149..b3c711b529 100644
--- a/ext/mcrypt/mcrypt.c
+++ b/ext/mcrypt/mcrypt.c
@@ -1398,10 +1398,12 @@ PHP_FUNCTION(mcrypt_create_iv)
/* It could be done using LoadLibrary but as we rely on 2k+ for 5.3, cleaner to use a clear dependency (Advapi32) and a
standard API call (no f=getAddr..; f();) */
if(!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
+ efree(iv);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Cannot open random device");
RETURN_FALSE;
}
if(!CryptGenRandom(hCryptProv, size, iv_b)) {
+ efree(iv);
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not gather sufficient random data");
RETURN_FALSE;
}