Commit 28290072b6576210f59210be6081f1d0b0a88b3b

Steffen Jaeckel 2019-05-21T18:05:56

Merge pull request #276 from libtom/fix-137 fix #137

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/bn_mp_div.c b/bn_mp_div.c
index 1bf4405..fad3d2a 100644
--- a/bn_mp_div.c
+++ b/bn_mp_div.c
@@ -213,7 +213,7 @@ mp_err mp_div(const mp_int *a, const mp_int *b, mp_int *c, mp_int *d)
 
          /* find right hand */
          t2.dp[0] = ((i - 2) < 0) ? 0u : x.dp[i - 2];
-         t2.dp[1] = ((i - 1) < 0) ? 0u : x.dp[i - 1];
+         t2.dp[1] = x.dp[i - 1]; /* i >= 1 always holds */
          t2.dp[2] = x.dp[i];
          t2.used = 3;
       } while (mp_cmp_mag(&t1, &t2) == MP_GT);