From 55ddfd58dd6e67e88cf9a3e55bf99550affe8b3f Mon Sep 17 00:00:00 2001 From: Jonathan Calvert Date: Tue, 10 Sep 2024 19:38:48 -0500 Subject: [PATCH] Fixes [Bug #20718] (#11576) Fixes [Bug #20718] 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 378e4a31cb..5ae6dc81bd 100644 --- a/gc.c +++ b/gc.c @@ -3491,7 +3491,7 @@ rb_data_free(rb_objspace_t *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); }