diff options
Diffstat (limited to 'random_bits.c')
-rw-r--r-- | random_bits.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/random_bits.c b/random_bits.c index 528b09e..a6d95a2 100644 --- a/random_bits.c +++ b/random_bits.c @@ -14,8 +14,10 @@ libsimple_random_bits(size_t bits, void *unused) bits -= 8; } - ret <<= bits; - ret |= (uintmax_t)(rand() & ((1 << bits) - 1)); + if (bits) { + ret <<= bits; + ret |= (uintmax_t)(rand() & ((1 << bits) - 1)); + } (void) unused; return ret; |