diff --git a/gc.c b/gc.c index 0adef25312e0b3..8583ee1a6d088a 100644 --- a/gc.c +++ b/gc.c @@ -1595,7 +1595,11 @@ rb_objspace_free_objects(void *objspace) int rb_objspace_garbage_object_p(VALUE obj) { - return rb_gc_impl_garbage_object_p(rb_gc_get_objspace(), obj); + void *objspace = rb_gc_get_objspace(); + if (!rb_gc_impl_pointer_to_heap_p(objspace, (void *)obj)) { + return TRUE; + } + return rb_gc_impl_garbage_object_p(objspace, obj); } /*