From: Nikos Mavrogiannopoulos Date: Sun, 25 May 2014 18:31:55 +0000 (+0200) Subject: avoid cleanup when there are no allocations in _gnutls_x509_der_encode(). X-Git-Tag: gnutls_3_3_3~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39adcb42eab7f743df0edcb36d726aa4f69db6ac;p=thirdparty%2Fgnutls.git avoid cleanup when there are no allocations in _gnutls_x509_der_encode(). --- 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) {