Skip to content

Commit b5a8c55

Browse files
committed
changes from feedback
1 parent fa54bc4 commit b5a8c55

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/gmp/gmp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,9 +1804,9 @@ ZEND_FUNCTION(gmp_random_bits)
18041804
}
18051805

18061806
#if SIZEOF_SIZE_T == 4
1807-
const zend_long maxbits = ULONG_MAX / GMP_NUMB_BITS;
1807+
const zend_long maxbits = (ULONG_MAX / GMP_NUMB_BITS) / sizeof(mp_limb_t);
18081808
#else
1809-
const zend_long maxbits = INT_MAX;
1809+
const zend_long maxbits = INT_MAX / sizeof(mp_limb_t);
18101810
#endif
18111811

18121812
if (bits <= 0 || bits > maxbits) {
@@ -1817,7 +1817,7 @@ ZEND_FUNCTION(gmp_random_bits)
18171817
INIT_GMP_RETVAL(gmpnum_result);
18181818
gmp_init_random();
18191819

1820-
mpz_urandomb(gmpnum_result, GMPG(rand_state), (mp_bitcnt_t)bits);
1820+
mpz_urandomb(gmpnum_result, GMPG(rand_state), bits);
18211821
}
18221822
/* }}} */
18231823

0 commit comments

Comments
 (0)