Skip to content

Resolving problems mentioned in #218 #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions bn_mp_ilogb.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ int mp_ilogb(mp_int *a, mp_digit base, mp_int *c)
}
if (base == 2u) {
cmp = mp_count_bits(a) - 1;
mp_set_int(c, (unsigned long)cmp);
if ((err = mp_set_int(c, (unsigned long)cmp)) != MP_OKAY) {
goto LBL_ERR;
}
return err;
}
if (a->used == 1) {
Expand Down Expand Up @@ -163,15 +165,21 @@ int mp_ilogb(mp_int *a, mp_digit base, mp_int *c)
mp_exch(&bracket_mid, &bracket_low);
}
if (cmp == MP_EQ) {
mp_set_int(c, (unsigned long)mid);
if ((err = mp_set_int(c, (unsigned long)mid)) != MP_OKAY) {
goto LBL_ERR;
}
goto LBL_END;
}
}

if (mp_cmp(&bracket_high, a) == MP_EQ) {
mp_set_int(c, (unsigned long)high);
if ((err = mp_set_int(c, (unsigned long)high)) != MP_OKAY) {
goto LBL_ERR;
}
} else {
mp_set_int(c, (unsigned long)low);
if ((err = mp_set_int(c, (unsigned long)low)) != MP_OKAY) {
goto LBL_ERR;
}
}

LBL_END:
Expand Down