summaryrefslogtreecommitdiff
path: root/lib/nettle
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2011-11-08 22:02:30 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2011-11-09 08:49:12 +0100
commit395d620849722bd7fef44cb540a6bb435694d626 (patch)
tree1d26d5f9f5b39963af62b825b2a5e46e2ca2749a /lib/nettle
parent8462e62e31fd8244ecf8c47cd7b6084837b9da17 (diff)
downloadgnutls-395d620849722bd7fef44cb540a6bb435694d626.tar.gz
release allocated memory on a cipher or mac failure to initialize.
Diffstat (limited to 'lib/nettle')
-rw-r--r--lib/nettle/cipher.c1
-rw-r--r--lib/nettle/mac.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/nettle/cipher.c b/lib/nettle/cipher.c
index 014a54924c..83da47379a 100644
--- a/lib/nettle/cipher.c
+++ b/lib/nettle/cipher.c
@@ -182,6 +182,7 @@ wrap_nettle_cipher_init (gnutls_cipher_algorithm_t algo, void **_ctx, int enc)
break;
default:
gnutls_assert ();
+ gnutls_free(ctx);
return GNUTLS_E_INVALID_REQUEST;
}
diff --git a/lib/nettle/mac.c b/lib/nettle/mac.c
index a0f4ea56a7..4a77895a27 100644
--- a/lib/nettle/mac.c
+++ b/lib/nettle/mac.c
@@ -177,7 +177,10 @@ wrap_nettle_hmac_init (gnutls_mac_algorithm_t algo, void **_ctx)
ret = _hmac_ctx_init(algo, ctx);
if (ret < 0)
- return gnutls_assert_val(ret);
+ {
+ gnutls_free(ctx);
+ return gnutls_assert_val(ret);
+ }
*_ctx = ctx;
@@ -372,6 +375,7 @@ wrap_nettle_hash_init (gnutls_digest_algorithm_t algo, void **_ctx)
if ((ret=_ctx_init( algo, ctx)) < 0)
{
gnutls_assert ();
+ gnutls_free(ctx);
return ret;
}