]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
avoid cleanup when there are no allocations in _gnutls_x509_der_encode().
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 25 May 2014 18:31:55 +0000 (20:31 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 29 May 2014 17:00:02 +0000 (19:00 +0200)
lib/x509/common.c

index 37c908782346f0196a8eadf8821c69268549d074..c0d0f3e2ffe442f064a17786802c977c70c6fd86 100644 (file)
@@ -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) {