s_mp_radix_size_overestimate: remove overflow check
This commit is contained in:
parent
6ac0b0c1b6
commit
3a744dc46d
@ -8,6 +8,7 @@ mp_err mp_grow(mp_int *a, int size)
|
||||
{
|
||||
/* if the alloc size is smaller alloc more ram */
|
||||
if (a->alloc < size) {
|
||||
/* TODO */
|
||||
/* reallocate the array a->dp
|
||||
*
|
||||
* We store the return in a temporary variable
|
||||
|
@ -8,6 +8,7 @@ mp_err mp_init_size(mp_int *a, int size)
|
||||
{
|
||||
size = MP_MAX(MP_MIN_PREC, size);
|
||||
|
||||
/*TODO*/
|
||||
/* alloc mem */
|
||||
a->dp = (mp_digit *) MP_CALLOC((size_t)size, sizeof(mp_digit));
|
||||
if (a->dp == NULL) {
|
||||
|
@ -52,12 +52,7 @@ mp_err s_mp_radix_size_overestimate(const mp_int *a, const int radix, size_t *si
|
||||
|
||||
if (MP_HAS(S_MP_LOG_2EXPT) && MP_IS_2EXPT((mp_digit)radix)) {
|
||||
/* floor(log_{2^n}(a)) + 1 + EOS + sign */
|
||||
*size = (size_t)(s_mp_log_2expt(a, (mp_digit)radix));
|
||||
/* Would overflow with base 2 otherwise */
|
||||
if (*size > (INT_MAX - 4)) {
|
||||
return MP_VAL;
|
||||
}
|
||||
*size += 3u;
|
||||
*size = (size_t)(s_mp_log_2expt(a, (mp_digit)radix) + 3);
|
||||
return MP_OKAY;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user