mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix an out of bound access
This commit is contained in:
parent
27adf5321e
commit
15d3b7fe6d
1 changed files with 6 additions and 0 deletions
6
struct.c
6
struct.c
|
@ -1793,6 +1793,12 @@ rb_data_initialize_m(int argc, const VALUE *argv, VALUE self)
|
|||
VALUE members = struct_ivar_get(klass, id_members);
|
||||
size_t num_members = RARRAY_LEN(members);
|
||||
|
||||
if (argc == 0) {
|
||||
if (num_members > 0) {
|
||||
rb_exc_raise(rb_keyword_error_new("missing", members));
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
if (argc > 1 || !RB_TYPE_P(argv[0], T_HASH)) {
|
||||
rb_raise(rb_eArgError, "wrong number of arguments (given %d, expected 0)", argc);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue