From b548d773b3140f7b3c38fdfe9393d2554742c626 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Fri, 26 Jul 2013 14:21:34 +0200 Subject: [PATCH] Fixed memory leak in ecdh_compute_shared() in case of error --- library/ecdh.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/ecdh.c b/library/ecdh.c index df21eac3e..301275aa2 100644 --- a/library/ecdh.c +++ b/library/ecdh.c @@ -65,7 +65,10 @@ int ecdh_compute_shared( const ecp_group *grp, mpi *z, MPI_CHK( ecp_mul( grp, &P, d, Q ) ); if( ecp_is_zero( &P ) ) - return( POLARSSL_ERR_ECP_BAD_INPUT_DATA ); + { + ret = POLARSSL_ERR_ECP_BAD_INPUT_DATA; + goto cleanup; + } MPI_CHK( mpi_copy( z, &P.X ) );