From fd6a1913813e6243bb98b5593f46b77ce8c5fc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Sat, 18 Jan 2014 19:05:23 +0100 Subject: [PATCH] Fix misplaced initialisation. If one of the calls to mpi_grow() before setting Apos would fail, then mpi_free( &Apos ) would be executed without Apos being initialised. --- library/bignum.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/bignum.c b/library/bignum.c index eb7a82257..680c25a93 100644 --- a/library/bignum.c +++ b/library/bignum.c @@ -1527,6 +1527,7 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR ) */ mpi_montg_init( &mm, N ); mpi_init( &RR ); mpi_init( &T ); + mpi_init( &Apos ); memset( W, 0, sizeof( W ) ); i = mpi_msb( E ); @@ -1546,8 +1547,6 @@ int mpi_exp_mod( mpi *X, const mpi *A, const mpi *E, const mpi *N, mpi *_RR ) * Compensate for negative A (and correct at the end) */ neg = ( A->s == -1 ); - - mpi_init( &Apos ); if( neg ) { MPI_CHK( mpi_copy( &Apos, A ) );