1
0
Fork 0
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:
Nobuyoshi Nakada 2022-10-01 16:14:59 +09:00
parent 27adf5321e
commit 15d3b7fe6d
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -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);
}