summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-05 11:13:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-05 11:13:18 +0000
commit2073258a7d192e8d2bc853e10464a7a5fcac8f2d (patch)
tree9c7290dc3a782104d0b14f2feaffc6131744f4e2 /random.c
parentb1ae6e473e1c1865a1dcd5e4e5d242345c20cc77 (diff)
obj_init_copy
* object.c (rb_obj_init_copy): should check if trusted too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/random.c b/random.c
index 9dbcbd1d62..d05fe6d9c6 100644
--- a/random.c
+++ b/random.c
@@ -596,9 +596,14 @@ random_get_seed(VALUE obj)
static VALUE
random_copy(VALUE obj, VALUE orig)
{
- rb_random_t *rnd1 = get_rnd(obj);
- rb_random_t *rnd2 = get_rnd(orig);
- struct MT *mt = &rnd1->mt;
+ rb_random_t *rnd1, *rnd2;
+ struct MT *mt;
+
+ if (!OBJ_INIT_COPY(obj, orig)) return obj;
+
+ rnd1 = get_rnd(obj);
+ rnd2 = get_rnd(orig);
+ mt = &rnd1->mt;
*rnd1 = *rnd2;
mt->next = mt->state + numberof(mt->state) - mt->left + 1;