]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
cleanup resources on _gnutls_ecc_ansi_x963_export() failure.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 25 May 2014 12:32:35 +0000 (14:32 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 29 May 2014 17:00:02 +0000 (19:00 +0200)
lib/gnutls_ecc.c

index 00f7a92d78f8f1db448d86a8864118d201f4d827..847f0d2e85760f9c36696c731a27687a7b84bcfe 100644 (file)
@@ -57,8 +57,10 @@ _gnutls_ecc_ansi_x963_export(gnutls_ecc_curve_t curve, bigint_t x,
        ret =
            _gnutls_mpi_print(x, &out->data[1 + (numlen - byte_size)],
                              &size);
-       if (ret < 0)
-               return gnutls_assert_val(ret);
+       if (ret < 0) {
+               gnutls_assert();
+               goto cleanup;
+       }
 
        byte_size = (_gnutls_mpi_get_nbits(y) + 7) / 8;
        size = out->size - (1 + (numlen + numlen - byte_size));
@@ -66,11 +68,16 @@ _gnutls_ecc_ansi_x963_export(gnutls_ecc_curve_t curve, bigint_t x,
            _gnutls_mpi_print(y,
                              &out->data[1 + numlen + numlen - byte_size],
                              &size);
-       if (ret < 0)
-               return gnutls_assert_val(ret);
+       if (ret < 0) {
+               gnutls_assert();
+               goto cleanup;
+       }
 
        /* pad and store y */
        return 0;
+ cleanup:
+       _gnutls_free_datum(out);
+       return ret;
 }