Fetch arguments earlier to avoid a crash.

This commit is contained in:
Clayton Smith
2017-02-02 16:35:59 -05:00
parent 6420951463
commit a8ccda5692
+2 -1
View File
@@ -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;