summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorMatt Valentine-House <matt@eightbitraptor.com>2021-11-10 22:42:40 +0000
committerPeter Zhu <peter@peterzhu.ca>2021-11-11 08:54:48 -0500
commitc53aecee3bec524b91d7f2534291802a1cabb3f5 (patch)
treeb905e87ada1b2d1748cc2839b69b26fb7a181e7a /gc.c
parentb5531adf4160304ca62b7d128af458704c9beb4e (diff)
fix a memory leak introduced in 8bbd319
This commit fixes a memory leak introduced in an early part of the variable width allocation project that would prevent the rb_classext_t struct from being free'd when the class is swept.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5103
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gc.c b/gc.c
index 3251719066..94c7f60c95 100644
--- a/gc.c
+++ b/gc.c
@@ -3141,8 +3141,10 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
}
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);
+#if !USE_RVARGC
if (RCLASS_EXT(obj))
- RCLASS_EXT(obj) = NULL;
+ xfree(RCLASS_EXT(obj));
+#endif
(void)RB_DEBUG_COUNTER_INC_IF(obj_module_ptr, BUILTIN_TYPE(obj) == T_MODULE);
(void)RB_DEBUG_COUNTER_INC_IF(obj_class_ptr, BUILTIN_TYPE(obj) == T_CLASS);
@@ -3308,7 +3310,9 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
cc_table_free(objspace, obj, FALSE);
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);
- RCLASS_EXT(obj) = NULL;
+#if !USE_RVARGC
+ xfree(RCLASS_EXT(obj));
+#endif
RB_DEBUG_COUNTER_INC(obj_iclass_ptr);
break;