Removed recursion from fix #309.
diff --git a/library/bignum.c b/library/bignum.c
index 5e25123..9c38117 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -859,22 +859,21 @@
     int ret;
     size_t i, j;
     mbedtls_mpi_uint *o, *p, c;
+    mbedtls_mpi TB;
 
     if( X == B )
     {
+        B = A; A = X;
+
         if( B == A )
         {
             // Making a temporary copy instead of shifting by one to deny
             // the possibility of corresponding side-channel attacks.
-            mbedtls_mpi TB;
-
             mbedtls_mpi_init( &TB );
             MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, B ) );
             
-            return mbedtls_mpi_add_abs( X, A, &TB );
+            B = &TB;
         }
-
-        B = A; A = X;
     }
 
     if( X != A )
@@ -911,6 +910,10 @@
     }
 
 cleanup:
+    if( &TB == B ) 
+    {
+        mbedtls_mpi_free( &TB );
+    }
 
     return( ret );
 }