8000 shape.c: fix off by one error in `shape_tree_mark` · ruby/ruby@29a2d85 · GitHub
[go: up one dir, main page]

Skip to content

Commit 29a2d85

Browse files
committed
shape.c: fix off by one error in shape_tree_mark
1 parent 3c14d2b commit 29a2d85

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

id_table.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ managed_id_table_dup_i(ID id, VALUE val, void *data)
381381
VALUE
382382
rb_managed_id_table_dup(VALUE old_table)
383383
{
384+
RUBY_ASSERT(RB_TYPE_P(old_table, T_DATA));
384385
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(old_table), &managed_id_table_type));
385386

386387
struct rb_id_table *new_tbl;
@@ -394,6 +395,7 @@ rb_managed_id_table_dup(VALUE old_table)
394395
int
395396
rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp)
396397
{
398+
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
397399
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));
398400

399401
return rb_id_table_lookup(RTYPEDDATA_GET_DATA(table), id, valp);
@@ -402,6 +404,7 @@ rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp)
402404
int
403405
rb_managed_id_table_insert(VALUE table, ID id, VALUE val)
404406
{
407+
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
405408
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));
406409

407410
return rb_id_table_insert(RTYPEDDATA_GET_DATA(table), id, val);
@@ -410,6 +413,7 @@ rb_managed_id_table_insert(VALUE table, ID id, VALUE val)
410413
size_t
411414
rb_managed_id_table_size(VALUE table)
412415
{
416+
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
413417
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));
414418

415419
return rb_id_table_size(RTYPEDDATA_GET_DATA(table));
@@ -418,6 +422,7 @@ rb_managed_id_table_size(VALUE table)
418422
void
419423
rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data)
420424
{
425+
RUBY_ASSERT(RB_TYPE_P(table, T_DATA));
421426
RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type));
422427

423428
rb_id_table_foreach(RTYPEDDATA_GET_DATA(table), func, data);

shape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static void
303303
shape_tree_mark(void *data)
304304
{
305305
rb_shape_t *cursor = rb_shape_get_root_shape();
306-
rb_shape_t *end = RSHAPE(GET_SHAPE_TREE()->next_shape_id);
306+
rb_shape_t *end = RSHAPE(GET_SHAPE_TREE()->next_shape_id - 1);
307307
while (cursor < end) {
308308
if (cursor->edges && !SINGLE_CHILD_P(cursor->edges)) {
309309
// FIXME: GC compaction may call `rb_shape_traverse_from_new_root`

0 commit comments

Comments
 (0)
0