diff --git a/ChangeLog b/ChangeLog index a78257803..f523d264c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,8 @@ Bugfix * Fix propagation of restart contexts in restartable EC operations. This could previously lead to segmentation faults in builds using an address-sanitizer and enabling but not using MBEDTLS_ECP_RESTARTABLE. + * Fix memory leak in in mpi_miller_rabin(). Contributed by + Jens Wiklander in #2363 Changes * Make it easier to define MBEDTLS_PARAM_FAILED as assert (which config.h diff --git a/library/bignum.c b/library/bignum.c index 41946183c..c6feada8b 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -2351,7 +2351,8 @@ static int mpi_miller_rabin( const mbedtls_mpi *X, size_t rounds, } if (count++ > 30) { - return MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + ret = MBEDTLS_ERR_MPI_NOT_ACCEPTABLE; + goto cleanup; } } while ( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 ||