The unified diff between revisions [0dc5b2d6..] and [b14c94b9..] is displayed below. It can also be downloaded as a raw diff.
This diff has been restricted to the following files: 'bn_mp_radix_size.c'
#
#
# patch "bn_mp_radix_size.c"
# from [891ae52347addbb788c35c3c11e4912c6f6d7c35]
# to [cea57d1d767181e6a51d13d3dd79684a4e62482a]
#
============================================================
--- bn_mp_radix_size.c 891ae52347addbb788c35c3c11e4912c6f6d7c35
+++ bn_mp_radix_size.c cea57d1d767181e6a51d13d3dd79684a4e62482a
@@ -35,22 +35,29 @@ int mp_radix_size (mp_int * a, int radix
return MP_VAL;
}
- /* init a copy of the input */
- if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
- return res;
+ if (mp_iszero(a) == MP_YES) {
+ *size = 2;
+ return MP_OKAY;
}
/* digs is the digit count */
digs = 0;
/* if it's negative add one for the sign */
- if (t.sign == MP_NEG) {
+ if (a->sign == MP_NEG) {
++digs;
- t.sign = MP_ZPOS;
}
+ /* init a copy of the input */
+ if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
+ return res;
+ }
+
+ /* force temp to positive */
+ t.sign = MP_ZPOS;
+
/* fetch out all of the digits */
- while (mp_iszero (&t) == 0) {
+ while (mp_iszero (&t) == MP_NO) {
if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
mp_clear (&t);
return res;