Skip to content

Commit 8a886c8

Browse files
czurniedensjaeckel
authored andcommitted
resolving #218
1 parent e9e2342 commit 8a886c8

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

bn_mp_ilogb.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ int mp_ilogb(mp_int *a, mp_digit base, mp_int *c)
9090
}
9191
if (base == 2u) {
9292
cmp = mp_count_bits(a) - 1;
93-
mp_set_int(c, (unsigned long)cmp);
93+
if ((err = mp_set_int(c, (unsigned long)cmp)) != MP_OKAY) {
94+
goto LBL_ERR;
95+
}
9496
return err;
9597
}
9698
if (a->used == 1) {
@@ -163,15 +165,21 @@ int mp_ilogb(mp_int *a, mp_digit base, mp_int *c)
163165
mp_exch(&bracket_mid, &bracket_low);
164166
}
165167
if (cmp == MP_EQ) {
166-
mp_set_int(c, (unsigned long)mid);
168+
if ((err = mp_set_int(c, (unsigned long)mid)) != MP_OKAY) {
169+
goto LBL_ERR;
170+
}
167171
goto LBL_END;
168172
}
169173
}
170174

171175
if (mp_cmp(&bracket_high, a) == MP_EQ) {
172-
mp_set_int(c, (unsigned long)high);
176+
if ((err = mp_set_int(c, (unsigned long)high)) != MP_OKAY) {
177+
goto LBL_ERR;
178+
}
173179
} else {
174-
mp_set_int(c, (unsigned long)low);
180+
if ((err = mp_set_int(c, (unsigned long)low)) != MP_OKAY) {
181+
goto LBL_ERR;
182+
}
175183
}
176184

177185
LBL_END:

0 commit comments

Comments
 (0)