Skip to content

Commit d518d44

Browse files
committed
rb_copy_generic_ivar: alloc the proper shape capacity
1 parent 4d7cf6d commit d518d44

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

variable.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,6 @@ general_field_set_at(VALUE obj, rb_shape_t *target_shape, VALUE val, void *data,
17201720
attr_index_t index = target_shape->next_field_index - 1;
17211721
if (index >= current_shape->capacity) {
17221722
shape_resize_fields_func(obj, current_shape->capacity, target_shape->capacity, data);
1723-
set_shape_func(obj, target_shape, data);
17241723
}
17251724

17261725
if (target_shape->next_field_index > current_shape->next_field_index) {
@@ -1750,7 +1749,7 @@ generic_fields_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int e
17501749

17511750
if (!existing || fields_lookup->resize) {
17521751
if (existing) {
1753-
RUBY_ASSERT(fields_lookup->shape->type == SHAPE_IVAR);
1752+
RUBY_ASSERT(fields_lookup->shape->type == SHAPE_IVAR || fields_lookup->shape->type == SHAPE_OBJ_ID);
17541753
RUBY_ASSERT(rb_shape_get_shape_by_id(fields_lookup->shape->parent_id)->capacity < fields_lookup->shape->capacity);
17551754
}
17561755
else {
@@ -2333,7 +2332,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
23332332
}
23342333
}
23352334

2336-
new_fields_tbl = gen_fields_tbl_resize(0, shape_to_set_on_dest->next_field_index);
2335+
new_fields_tbl = gen_fields_tbl_resize(0, shape_to_set_on_dest->capacity);
23372336

23382337
VALUE *src_buf = obj_fields_tbl->as.shape.fields;
23392338
VALUE *dest_buf = new_fields_tbl->as.shape.fields;

0 commit comments

Comments
 (0)