Fetch arguments earlier to avoid a crash.
@@ -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;
