mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-struct/struct.c (mrb_struct_to_h): RSTRUCT_PTR() may be NULL
Especially when you define a member named `initialize`.
This commit is contained in:
@@ -619,7 +619,7 @@ mrb_struct_to_h(mrb_state *mrb, mrb_value self)
|
||||
ret = mrb_hash_new_capa(mrb, RARRAY_LEN(members));
|
||||
|
||||
for (i = 0; i < RARRAY_LEN(members); i++) {
|
||||
mrb_hash_set(mrb, ret, RARRAY_PTR(members)[i], RSTRUCT_PTR(self)[i]);
|
||||
mrb_hash_set(mrb, ret, RARRAY_PTR(members)[i], mrb_ary_ref(mrb, self, i));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user