Permalink
Browse files

Fetch arguments earlier to avoid a crash.

  • Loading branch information...
clayton-shopify committed Feb 2, 2017
1 parent 6420951 commit a8ccda5692de601d014a942ee1ea2129388ce84c
Showing with 2 additions and 1 deletion.
  1. +2 −1 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;

0 comments on commit a8ccda5

Please sign in to comment.