summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
Diffstat (limited to 'random.c')
-rw-r--r--random.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/random.c b/random.c
index 3ae9197277..bcc16aa5b3 100644
--- a/random.c
+++ b/random.c
@@ -414,8 +414,8 @@ limited_rand(struct MT *mt, unsigned long limit)
retry:
val = 0;
for (i = SIZEOF_LONG/4-1; 0 <= i; i--) {
- if (mask >> (i * 32)) {
- val |= genrand_int32(mt) << (i * 32);
+ if ((mask >> (i * 32)) & 0xffffffff) {
+ val |= (unsigned long)genrand_int32(mt) << (i * 32);
val &= mask;
if (limit < val)
goto retry;