diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-13 15:34:13 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2018-08-13 23:15:52 +0900 |
| commit | 14206a75a37020a3a4926b1289a1f07277b78578 (patch) | |
| tree | 02c35a7075b08344d5fbec43334acc611fa32a5c | |
| parent | 1e52d47bc3e0d287e5d2cf5c61df60f8613db2aa (diff) | |
| download | mruby-14206a75a37020a3a4926b1289a1f07277b78578.tar.gz mruby-14206a75a37020a3a4926b1289a1f07277b78578.zip | |
Remove potential path to avoid uninitialized variable access.
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index fe7e73f04..b567a00d5 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -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 |
