diff options
author | Nikita Popov <nikic@php.net> | 2014-03-02 23:26:46 +0100 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2014-03-05 15:32:32 +0100 |
commit | b9737aa08ea2228e23b3f9289189a14a7cfda800 (patch) | |
tree | 72392b9c75f590c0ddd53368db92ac631bbd7cea | |
parent | e4876ecbfb36a0a3de8f0a10ab20d607932cf59e (diff) | |
download | php-git-b9737aa08ea2228e23b3f9289189a14a7cfda800.tar.gz |
Call mcrypt_module_close on error
-rw-r--r-- | ext/mcrypt/mcrypt.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index a9f34d77f5..a8dbc4203a 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -1268,6 +1268,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons /* Checking for key-length */ if (php_mcrypt_ensure_valid_key_size(td, key_len TSRMLS_CC) == FAILURE) { + mcrypt_module_close(td); RETURN_FALSE; } @@ -1275,11 +1276,13 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons if (mcrypt_enc_mode_has_iv(td) == 1) { if (!iv) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Encryption mode requires an initialization vector"); + mcrypt_module_close(td); RETURN_FALSE; } if (iv_len != mcrypt_enc_get_iv_size(td)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, MCRYPT_IV_WRONG_SIZE); + mcrypt_module_close(td); RETURN_FALSE; } } @@ -1299,6 +1302,7 @@ static void php_mcrypt_do_crypt(char* cipher, const char *key, int key_len, cons if (mcrypt_generic_init(td, (void *) key, key_len, (void *) iv) < 0) { php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Mcrypt initialisation failed"); + mcrypt_module_close(td); RETURN_FALSE; } |