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).
This commit is contained in:
Peter Zhu 2024-12-16 10:49:49 -05:00
parent 50a67820fb
commit 9733304d61
Notes: git 2024-12-17 16:03:57 +00:00

2
gc.c
View File

@ -2427,6 +2427,8 @@ gc_location_internal(void *objspace, VALUE value)
return value;
}
GC_ASSERT(rb_gc_impl_pointer_to_heap_p(objspace, (void *)value));
return rb_gc_impl_location(objspace, value);
}