summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-21 14:51:17 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-21 14:51:17 +0000
commit4516f623b8628e8b424197cf29c786172f23e1ad (patch)
tree9e8835e2e2a3334b5e56072a35f6eddf3de732b6 /random.c
parent7203e59f275dfe6f0b6e6f301673400565c5e0dc (diff)
* random.c (rand_init): array length of random seed was broken, which
causes memory error with srand(2**1000000-1). * test/ruby/test_rand.c: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/random.c b/random.c
index e128c61e5f..ddaaedc5a8 100644
--- a/random.c
+++ b/random.c
@@ -304,11 +304,9 @@ rand_init(struct MT *mt, VALUE vseed)
if (blen == 0) {
len = 1;
}
- else if (blen > MT_MAX_STATE * SIZEOF_INT32 / SIZEOF_BDIGITS) {
- blen = (len = MT_MAX_STATE) * SIZEOF_INT32 / SIZEOF_BDIGITS;
- len = roomof(len, SIZEOF_INT32);
- }
else {
+ if (blen > MT_MAX_STATE * SIZEOF_INT32 / SIZEOF_BDIGITS)
+ blen = (len = MT_MAX_STATE) * SIZEOF_INT32 / SIZEOF_BDIGITS;
len = roomof((int)blen * SIZEOF_BDIGITS, SIZEOF_INT32);
}
/* allocate ints for init_by_array */