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
This commit is contained in:
Jonathan Calvert 2024-09-10 19:38:48 -05:00 committed by GitHub
parent 948ca04a76
commit 55ddfd58dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

2
gc.c
View file

@ -3491,7 +3491,7 @@ rb_data_free(rb_objspace_t *objspace, VALUE obj)
if (dfree) { if (dfree) {
if (dfree == RUBY_DEFAULT_FREE) { if (dfree == RUBY_DEFAULT_FREE) {
if (!RTYPEDDATA_EMBEDDED_P(obj)) { if (!RTYPEDDATA_P(obj) || !RTYPEDDATA_EMBEDDED_P(obj)) {
xfree(data); xfree(data);
RB_DEBUG_COUNTER_INC(obj_data_xfree); RB_DEBUG_COUNTER_INC(obj_data_xfree);
} }