Skip to content

Commit bb218f9

Browse files
committed
rb_copy_generic_ivar: alloc the proper shape capacity
1 parent 3b61eb6 commit bb218f9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

variable.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,9 @@ 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_ivptr_func(obj, current_shape->capacity, target_shape->capacity, data);
1722+
}
1723+
1724+
if (target_shape->next_field_index > current_shape->next_field_index) {
17221725
set_shape_func(obj, target_shape, data);
17231726
}
17241727

@@ -1745,7 +1748,7 @@ generic_ivar_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int exi
17451748

17461749
if (!existing || ivar_lookup->resize) {
17471750
if (existing) {
1748-
RUBY_ASSERT(ivar_lookup->shape->type == SHAPE_IVAR);
1751+
RUBY_ASSERT(ivar_lookup->shape->type == SHAPE_IVAR || ivar_lookup->shape->type == SHAPE_OBJ_ID);
17491752
RUBY_ASSERT(rb_shape_get_shape_by_id(ivar_lookup->shape->parent_id)->capacity < ivar_lookup->shape->capacity);
17501753
}
17511754
else {
@@ -2328,7 +2331,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
23282331
}
23292332
}
23302333

2331-
new_ivtbl = gen_ivtbl_resize(0, shape_to_set_on_dest->next_field_index);
2334+
new_ivtbl = gen_ivtbl_resize(0, shape_to_set_on_dest->capacity);
23322335

23332336
VALUE *src_buf = obj_ivtbl->as.shape.ivptr;
23342337
VALUE *dest_buf = new_ivtbl->as.shape.ivptr;

0 commit comments

Comments
 (0)