Skip to content

Commit 1670a2d

Browse files
committed
rb_copy_generic_ivar: alloc the proper shape capacity
1 parent 2a6ec7d commit 1670a2d

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
@@ -1719,7 +1719,6 @@ general_field_set_at(VALUE obj, rb_shape_t *target_shape, VALUE val, void *data,
17191719
attr_index_t index = target_shape->next_field_index - 1;
17201720
if (index >= current_shape->capacity) {
17211721
shape_resize_fields_func(obj, current_shape->capacity, target_shape->capacity, data);
1722-
set_shape_func(obj, target_shape, data);
17231722
}
17241723

17251724
if (target_shape->next_field_index > current_shape->next_field_index) {
@@ -1749,7 +1748,7 @@ generic_fields_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int e
17491748

17501749
if (!existing || fields_lookup->resize) {
17511750
if (existing) {
1752-
RUBY_ASSERT(fields_lookup->shape->type == SHAPE_IVAR);
1751+
RUBY_ASSERT(fields_lookup->shape->type == SHAPE_IVAR || fields_lookup->shape->type == SHAPE_OBJ_ID);
17531752
RUBY_ASSERT(rb_shape_get_shape_by_id(fields_lookup->shape->parent_id)->capacity < fields_lookup->shape->capacity);
17541753
}
17551754
else {
@@ -2332,7 +2331,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
23322331
}
23332332
}
23342333

2335-
new_fields_tbl = gen_fields_tbl_resize(0, shape_to_set_on_dest->next_field_index);
2334+
new_fields_tbl = gen_fields_tbl_resize(0, shape_to_set_on_dest->capacity);
23362335

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

0 commit comments

Comments
 (0)