[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.
This commit is contained in:
Jonathan Calvert 2024-09-06 22:19:47 -05:00 committed by GitHub
parent 6dc9384694
commit c1a510a8df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-09-07 03:20:07 +00:00
Merged: https://github.com/ruby/ruby/pull/11563

Merged-By: nobu <nobu@ruby-lang.org>

2
gc.c
View File

@ -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);
}