Skip to content

Commit 9733304

Browse files
committed
Assert Ruby object in rb_gc_location
rb_gc_location doesn't check that the object is actually a Ruby object and only checks if the object looks like a T_MOVED. This may have unexpected outcomes if the object is not a Ruby object (e.g. a piece of malloc memory may be corrupted).
1 parent 50a6782 commit 9733304

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

gc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,8 @@ gc_location_internal(void *objspace, VALUE value)
24272427
return value;
24282428
}
24292429

2430+
GC_ASSERT(rb_gc_impl_pointer_to_heap_p(objspace, (void *)value));
2431+
24302432
return rb_gc_impl_location(objspace, value);
24312433
}
24322434

0 commit comments

Comments
 (0)