Fix overflow in prng_range().
Add jemalloc_ffs64() and use it instead of jemalloc_ffsl() in prng_range(), since long is not guaranteed to be a 64-bit type.
This commit is contained in:
@@ -64,7 +64,7 @@ prng_range(uint64_t *state, uint64_t range)
|
||||
assert(range > 1);
|
||||
|
||||
/* Compute the ceiling of lg(range). */
|
||||
lg_range = jemalloc_ffsl(pow2_ceil_u64(range)) - 1;
|
||||
lg_range = jemalloc_ffs64(pow2_ceil_u64(range)) - 1;
|
||||
|
||||
/* Generate a result in [0..range) via repeated trial. */
|
||||
do {
|
||||
|
Reference in New Issue
Block a user