mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-struct (struct_index): avoid direct array indexing
Caused crash probably due to the combination of C++ UB & optimizer.
This commit is contained in:
@@ -393,7 +393,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)
|
||||
{
|
||||
return RSTRUCT_PTR(s)[struct_index(mrb, i, RSTRUCT_LEN(s))];
|
||||
mrb_int idx = struct_index(mrb, i, RSTRUCT_LEN(s));
|
||||
return RSTRUCT_PTR(s)[idx];
|
||||
}
|
||||
|
||||
/* 15.2.18.4.2 */
|
||||
|
||||
Reference in New Issue
Block a user