Skip to content

Commit

Permalink
check for stack address passed to rb_gc_register_address()
Browse files Browse the repository at this point in the history
  • Loading branch information
XrXr committed Dec 18, 2024
1 parent 5e1ceff commit 82e703f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2957,7 +2957,14 @@ rb_gc_register_mark_object(VALUE obj)
void
rb_gc_register_address(VALUE *addr)
{
VALUE *stack_start, *stack_end;
rb_vm_t *vm = GET_VM();
const rb_execution_context_t *ec = GET_EC();

GET_STACK_BOUNDS(stack_start, stack_end, 0);
if (stack_start && stack_start <= addr && addr < stack_end) {
rb_bug("rb_gc_register_address: %p<=%p<%p is a stack address", (void *)stack_start, (void *)addr, (void *)stack_end);
}

VALUE obj = *addr;

Expand Down

0 comments on commit 82e703f

Please sign in to comment.