Commit d2b739ee185e2c61dad9e9e1343e5c3c19157ee2

Francois Perrad 2019-10-06T15:47:13

don't overwrite MP_VAL value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/bn_mp_to_ubin.c b/bn_mp_to_ubin.c
index a6ded96..d359986 100644
--- a/bn_mp_to_ubin.c
+++ b/bn_mp_to_ubin.c
@@ -26,7 +26,7 @@ mp_err mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *wr
    while (!MP_IS_ZERO(&t)) {
       if (maxlen == 0u) {
          err = MP_VAL;
-         break;
+         goto LBL_ERR;
       }
       maxlen--;
 #ifndef MP_8BIT
@@ -39,7 +39,6 @@ mp_err mp_to_ubin(const mp_int *a, unsigned char *buf, size_t maxlen, size_t *wr
       }
    }
    s_mp_reverse(buf, x);
-   err = MP_OKAY;
 
    if (written != NULL) {
       *written = x;