From: Nikos Mavrogiannopoulos Date: Wed, 14 May 2014 13:47:48 +0000 (+0200) Subject: Eliminated memory leak on failed curve assignment. X-Git-Tag: gnutls_3_3_3~65 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6007caf68c3ca198734ecf78df5abb4cb902e63b;p=thirdparty%2Fgnutls.git Eliminated memory leak on failed curve assignment. The memory leak was uncovered by the Codenomicon TLS suite. --- diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c index 303cbaa78e..4422ff02ab 100644 --- a/lib/nettle/pk.c +++ b/lib/nettle/pk.c @@ -130,8 +130,10 @@ _ecc_params_to_privkey(const gnutls_pk_params_st * pk_params, const struct ecc_curve *curve) { ecc_scalar_init(priv, curve); - if (ecc_scalar_set(priv, pk_params->params[ECC_K]) == 0) + if (ecc_scalar_set(priv, pk_params->params[ECC_K]) == 0) { + ecc_scalar_clear(priv); return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + } return 0; } @@ -142,8 +144,10 @@ _ecc_params_to_pubkey(const gnutls_pk_params_st * pk_params, { ecc_point_init(pub, curve); if (ecc_point_set - (pub, pk_params->params[ECC_X], pk_params->params[ECC_Y]) == 0) + (pub, pk_params->params[ECC_X], pk_params->params[ECC_Y]) == 0) { + ecc_point_clear(pub); return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + } return 0; }