summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-random/src/random.c
diff options
context:
space:
mode:
authorClayton Smith <[email protected]>2017-02-02 16:35:59 -0500
committerClayton Smith <[email protected]>2017-02-02 16:35:59 -0500
commita8ccda5692de601d014a942ee1ea2129388ce84c (patch)
tree757c30997e96faa2fafdfff42e80c31739447dca /mrbgems/mruby-random/src/random.c
parent6420951463ec9ace9eecb50923dc6a1925a45d31 (diff)
downloadmruby-a8ccda5692de601d014a942ee1ea2129388ce84c.tar.gz
mruby-a8ccda5692de601d014a942ee1ea2129388ce84c.zip
Fetch arguments earlier to avoid a crash.
Diffstat (limited to 'mrbgems/mruby-random/src/random.c')
-rw-r--r--mrbgems/mruby-random/src/random.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mrbgems/mruby-random/src/random.c b/mrbgems/mruby-random/src/random.c
index 587e6c01a..f81d38fe6 100644
--- a/mrbgems/mruby-random/src/random.c
+++ b/mrbgems/mruby-random/src/random.c
@@ -124,6 +124,8 @@ mrb_random_init(mrb_state *mrb, mrb_value self)
mrb_value seed;
mt_state *t;
+ seed = get_opt(mrb);
+
/* avoid memory leaks */
t = (mt_state*)DATA_PTR(self);
if (t) {
@@ -134,7 +136,6 @@ mrb_random_init(mrb_state *mrb, mrb_value self)
t = (mt_state *)mrb_malloc(mrb, sizeof(mt_state));
t->mti = N + 1;
- seed = get_opt(mrb);
seed = mrb_random_mt_srand(mrb, t, seed);
if (mrb_nil_p(seed)) {
t->has_seed = FALSE;