We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa54bc4 commit b5a8c55Copy full SHA for b5a8c55
ext/gmp/gmp.c
@@ -1804,9 +1804,9 @@ ZEND_FUNCTION(gmp_random_bits)
1804
}
1805
1806
#if SIZEOF_SIZE_T == 4
1807
- const zend_long maxbits = ULONG_MAX / GMP_NUMB_BITS;
+ const zend_long maxbits = (ULONG_MAX / GMP_NUMB_BITS) / sizeof(mp_limb_t);
1808
#else
1809
- const zend_long maxbits = INT_MAX;
+ const zend_long maxbits = INT_MAX / sizeof(mp_limb_t);
1810
#endif
1811
1812
if (bits <= 0 || bits > maxbits) {
@@ -1817,7 +1817,7 @@ ZEND_FUNCTION(gmp_random_bits)
1817
INIT_GMP_RETVAL(gmpnum_result);
1818
gmp_init_random();
1819
1820
- mpz_urandomb(gmpnum_result, GMPG(rand_state), (mp_bitcnt_t)bits);
+ mpz_urandomb(gmpnum_result, GMPG(rand_state), bits);
1821
1822
/* }}} */
1823
0 commit comments