variable.c: avoid out of bound write in generic_field_set

[Bug #21445]
This commit is contained in:
Jean Boussier 2025-06-21 13:43:50 +01:00
parent 0cec4a14fb
commit edbd9ed468
2 changed files with 9 additions and 1 deletions

View file

@ -1922,7 +1922,7 @@ generic_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val)
else {
attr_index_t index = RSHAPE_INDEX(target_shape_id);
if (index >= RSHAPE_CAPACITY(current_shape_id)) {
fields_obj = rb_imemo_fields_new(rb_obj_class(obj), index);
fields_obj = rb_imemo_fields_new(rb_obj_class(obj), RSHAPE_CAPACITY(target_shape_id));
if (original_fields_obj) {
attr_index_t fields_count = RSHAPE_LEN(current_shape_id);
VALUE *fields = rb_imemo_fields_ptr(fields_obj);