From c1a510a8dffa1c8065e47697cd57edae67126712 Mon Sep 17 00:00:00 2001 From: Jonathan Calvert Date: Fri, 6 Sep 2024 22:19:47 -0500 Subject: [PATCH] [Bug #20718] Free non-`RTypedData` objects Allow objects that are not of type `RTypedData` to use the default free function, as `RTYPEDDATA_EMBEDDED_P` can return a false positive when casting non-`RTypedData` objects. --- gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 3234784797..c653134695 100644 --- a/gc.c +++ b/gc.c @@ -1051,7 +1051,7 @@ rb_data_free(void *objspace, VALUE obj) if (dfree) { if (dfree == RUBY_DEFAULT_FREE) { - if (!RTYPEDDATA_EMBEDDED_P(obj)) { + if (!RTYPEDDATA_P(obj) || !RTYPEDDATA_EMBEDDED_P(obj)) { xfree(data); RB_DEBUG_COUNTER_INC(obj_data_xfree); }