Commit b722832b32578f0d42342d52e1adbe1a21ec6cbe

Steffen Jaeckel 2018-12-26T16:22:58

Merge pull request #140 from libtom/fix/missing_check fix missing check of return value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/bn_mp_prime_is_prime.c b/bn_mp_prime_is_prime.c
index 4915ab8..ce6958a 100644
--- a/bn_mp_prime_is_prime.c
+++ b/bn_mp_prime_is_prime.c
@@ -335,7 +335,9 @@ int mp_prime_is_prime(const mp_int *a, int t, int *result)
          len = mp_count_bits(&b);
          if (len > size_a) {
             len = len - size_a;
-            mp_div_2d(&b, len, &b, NULL);
+            if ((err = mp_div_2d(&b, len, &b, NULL)) != MP_OKAY) {
+               goto LBL_B;
+            }
          }
 
          /* Although the chance for b <= 3 is miniscule, try again. */