summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-25 20:31:55 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2014-05-29 19:00:02 +0200
commit39adcb42eab7f743df0edcb36d726aa4f69db6ac (patch)
treee4474382277a027b49429c51a2421f4daaaf9dc6
parent8b5f77110f4cfa94b22d2c5a3643da48726db690 (diff)
downloadgnutls-39adcb42eab7f743df0edcb36d726aa4f69db6ac.tar.gz
avoid cleanup when there are no allocations in _gnutls_x509_der_encode().
-rw-r--r--lib/x509/common.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/x509/common.c b/lib/x509/common.c
index 37c9087823..c0d0f3e2ff 100644
--- a/lib/x509/common.c
+++ b/lib/x509/common.c
@@ -1179,10 +1179,10 @@ _gnutls_x509_der_encode(ASN1_TYPE src, const char *src_name,
size = 0;
result = asn1_der_coding(src, src_name, NULL, &size, NULL);
+ /* this check explicitly covers the case where size == 0 && result == 0 */
if (result != ASN1_MEM_ERROR) {
gnutls_assert();
- result = _gnutls_asn2err(result);
- goto cleanup;
+ return _gnutls_asn2err(result);
}
/* allocate data for the der
@@ -1195,8 +1195,7 @@ _gnutls_x509_der_encode(ASN1_TYPE src, const char *src_name,
data = gnutls_malloc((size_t) size);
if (data == NULL) {
gnutls_assert();
- result = GNUTLS_E_MEMORY_ERROR;
- goto cleanup;
+ return GNUTLS_E_MEMORY_ERROR;
}
result = asn1_der_coding(src, src_name, data, &size, NULL);
@@ -1389,7 +1388,6 @@ _gnutls_x509_encode_and_copy_PKI_params(ASN1_TYPE dst,
".algorithm.parameters");
result = asn1_write_value(dst, name, der.data, der.size);
-
_gnutls_free_datum(&der);
if (result != ASN1_SUCCESS) {