Commit 4d6a3cdc93024cf2e456a62c363342f15d7421f3

Francois Perrad 2018-12-01T08:35:22

handle the last value of res

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/bn_mp_set_double.c b/bn_mp_set_double.c
index f0de20c..6d84874 100644
--- a/bn_mp_set_double.c
+++ b/bn_mp_set_double.c
@@ -38,6 +38,10 @@ int mp_set_double(mp_int *a, double b)
    }
 
    res = (exp < 0) ? mp_div_2d(a, -exp, a, NULL) : mp_mul_2d(a, exp, a);
+   if (res != MP_OKAY) {
+      return res;
+   }
+
    if (((cast.bits >> 63) != 0ULL) && (mp_iszero(a) == MP_NO)) {
       SIGN(a) = MP_NEG;
    }