diff --git a/gc/default/default.c b/gc/default/default.c index 94828be55d..e8d43986b9 100644 --- a/gc/default/default.c +++ b/gc/default/default.c @@ -7936,10 +7936,11 @@ static inline size_t objspace_malloc_size(rb_objspace_t *objspace, void *ptr, size_t hint) { #ifdef HAVE_MALLOC_USABLE_SIZE - return malloc_usable_size(ptr); -#else - return hint; + if (!hint) { + hint = malloc_usable_size(ptr); + } #endif + return hint; } enum memop_type {