mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fetch arguments earlier to avoid a crash.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user