- Moved to prevent uninitialized exit var
diff --git a/library/bignum.c b/library/bignum.c
index e73a810..08cbf8c 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -1397,19 +1397,6 @@
return( POLARSSL_ERR_MPI_BAD_INPUT_DATA );
/*
- * Compensate for negative A (and correct at the end)
- */
- neg = ( A->s == -1 );
-
- mpi_init( &Apos );
- if( neg )
- {
- MPI_CHK( mpi_copy( &Apos, A ) );
- Apos.s = 1;
- A = &Apos;
- }
-
- /*
* Init temps and window size
*/
mpi_montg_init( &mm, N );
@@ -1430,6 +1417,19 @@
MPI_CHK( mpi_grow( &T, j * 2 ) );
/*
+ * Compensate for negative A (and correct at the end)
+ */
+ neg = ( A->s == -1 );
+
+ mpi_init( &Apos );
+ if( neg )
+ {
+ MPI_CHK( mpi_copy( &Apos, A ) );
+ Apos.s = 1;
+ A = &Apos;
+ }
+
+ /*
* If 1st call, pre-compute R^2 mod N
*/
if( _RR == NULL || _RR->p == NULL )