Skip to content

Commit

Permalink
Bail out before pushing unexpected object
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Apr 2, 2020
1 parent 2544bf9 commit 2a4049b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4629,6 +4629,18 @@ free_stack_chunks(mark_stack_t *stack)
static void
push_mark_stack(mark_stack_t *stack, VALUE data)
{
VALUE obj = data;
switch (BUILTIN_TYPE(obj)) {
case T_NIL:
case T_FIXNUM:
rb_bug("push_mark_stack() called for broken object");
break;

case T_NODE:
UNEXPECTED_NODE(push_mark_stack);
break;
}

if (stack->index == stack->limit) {
push_mark_stack_chunk(stack);
}
Expand Down

0 comments on commit 2a4049b

Please sign in to comment.