Skip to content

Commit

Permalink
Remove potential path to avoid uninitialized variable access.
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Aug 25, 2018
1 parent fbfe519 commit 3182718
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions mrbgems/mruby-struct/src/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,19 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass)
}
}
rest = mrb_ary_new_from_values(mrb, argcnt, pargv);
for (i=0; i<RARRAY_LEN(rest); i++) {
for (i=0; i<argcnt; i++) {
id = mrb_obj_to_sym(mrb, RARRAY_PTR(rest)[i]);
mrb_ary_set(mrb, rest, i, mrb_symbol_value(id));
}
}
st = make_struct(mrb, name, rest, mrb_class_ptr(klass));
if (!mrb_nil_p(b)) {
mrb_yield_with_class(mrb, b, 1, &st, st, mrb_class_ptr(st));
}
st = make_struct(mrb, name, rest, mrb_class_ptr(klass));
if (!mrb_nil_p(b)) {
mrb_yield_with_class(mrb, b, 1, &st, st, mrb_class_ptr(st));
}

return st;
return st;
}
/* not reached */
return mrb_nil_value();
}

static mrb_int
Expand Down

0 comments on commit 3182718

Please sign in to comment.