summaryrefslogtreecommitdiff
path: root/lib/crypto-api.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-11-29 17:16:41 +0100
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-11-29 17:17:53 +0100
commit502be130493e8ce802cdf60fffdbb5f1885352a5 (patch)
treeb9e99feb614800281cd43320f56db2fc2d336941 /lib/crypto-api.c
parentdaf9baea106f18313c6704f5a4c0379a0777c337 (diff)
downloadgnutls-502be130493e8ce802cdf60fffdbb5f1885352a5.tar.gz
gnutls_aead_cipher_init: corrected potential memory leak
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/crypto-api.c')
-rw-r--r--lib/crypto-api.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/crypto-api.c b/lib/crypto-api.c
index 1a0b13b90c..788627a118 100644
--- a/lib/crypto-api.c
+++ b/lib/crypto-api.c
@@ -641,12 +641,13 @@ typedef struct api_aead_cipher_hd_st {
*
* Since: 3.4.0
**/
-int gnutls_aead_cipher_init(gnutls_aead_cipher_hd_t * handle,
+int gnutls_aead_cipher_init(gnutls_aead_cipher_hd_t *handle,
gnutls_cipher_algorithm_t cipher,
- const gnutls_datum_t * key)
+ const gnutls_datum_t *key)
{
api_aead_cipher_hd_st *h;
- const cipher_entry_st* e;
+ const cipher_entry_st *e;
+ int ret;
e = cipher_to_entry(cipher);
if (e == NULL || e->type != CIPHER_AEAD)
@@ -660,9 +661,14 @@ int gnutls_aead_cipher_init(gnutls_aead_cipher_hd_t * handle,
h = *handle;
- return
+ ret =
_gnutls_cipher_init(&h->ctx_enc, e, key,
NULL, 1);
+ if (ret < 0) {
+ gnutls_free(*handle);
+ *handle = NULL;
+ }
+ return ret;
}
/**