diff options
-rw-r--r-- | mpi/mpiutil.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index d3264c72..99402b82 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -582,11 +582,15 @@ void _gcry_mpi_swap_cond (gcry_mpi_t a, gcry_mpi_t b, unsigned long swap) { mpi_size_t i; - mpi_size_t nlimbs = a->alloced; + mpi_size_t nlimbs; mpi_limb_t mask = ((mpi_limb_t)0) - swap; mpi_limb_t x; - if (a->alloced != b->alloced) + if (a->alloced > b->alloced) + nlimbs = b->alloced; + else + nlimbs = a->alloced; + if (a->nlimbs > nlimbs || b->nlimbs > nlimbs) log_bug ("mpi_swap_cond: different sizes\n"); for (i = 0; i < nlimbs; i++) |