summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2017-04-21 09:28:47 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2017-04-21 15:14:14 +0200
commit4c08f343e4fe7b8136e2190f886a6947beab5591 (patch)
tree58fbc262ccd697147614508d2c0e8c527649d764
parent54b436cfef788c6ff347cc04466afb5811e921d0 (diff)
downloadgnutls-tmp-base64-decode-fix.tar.gz
_gnutls_base64_decode: addressed memory leak in decodingtmp-base64-decode-fix
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
-rw-r--r--lib/x509_b64.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/x509_b64.c b/lib/x509_b64.c
index 44e3b47a41..884f4da481 100644
--- a/lib/x509_b64.c
+++ b/lib/x509_b64.c
@@ -263,8 +263,10 @@ _gnutls_base64_decode(const uint8_t * data, size_t data_size,
size = BASE64_DECODE_LENGTH(data_size);
result->data = gnutls_malloc(size);
- if (result->data == NULL)
- return gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
+ if (result->data == NULL) {
+ ret = gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
+ goto cleanup;
+ }
ret = base64_decode_update(&ctx, &size, result->data,
pdata.size, pdata.data);
@@ -277,8 +279,10 @@ _gnutls_base64_decode(const uint8_t * data, size_t data_size,
}
ret = base64_decode_final(&ctx);
- if (ret != 1)
- return gnutls_assert_val(GNUTLS_E_PARSING_ERROR);
+ if (ret != 1) {
+ ret = gnutls_assert_val(GNUTLS_E_PARSING_ERROR);
+ goto cleanup;
+ }
result->size = size;