mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-struct/struct.c (struct_aref_int): update index check
Check should use the number of members, not the actual size of the struct object, which may be smaller than the declared size.
This commit is contained in:
@@ -399,7 +399,8 @@ struct_index(mrb_state *mrb, mrb_int i, mrb_int len)
|
||||
static mrb_value
|
||||
struct_aref_int(mrb_state *mrb, mrb_value s, mrb_int i)
|
||||
{
|
||||
mrb_int idx = struct_index(mrb, i, RSTRUCT_LEN(s));
|
||||
mrb_int idx = struct_index(mrb, i, num_members(mrb, s));
|
||||
if (idx >= RSTRUCT_LEN(s)) return mrb_nil_value();
|
||||
return RSTRUCT_PTR(s)[idx];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user