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:
Yukihiro "Matz" Matsumoto
2023-05-24 17:48:51 +09:00
parent 53de96426a
commit 7b7ea70b84
+1 -1
View File
@@ -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;