aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorAdam Hess <adamhess1991@gmail.com>2023-09-20 09:26:31 -0700
committerPeter Zhu <peter@peterzhu.ca>2023-09-22 09:44:58 -0400
commit8b236e0c66da8f92e9fc33de66cfbc8e4b0c0763 (patch)
tree8154d0859136c1a4e5fa51a4267f448f3c1fab32 /vm_insnhelper.c
parentf59b488b5a7f6e46e3e6d80d2b0a269e7d937a30 (diff)
downloadruby-8b236e0c66da8f92e9fc33de66cfbc8e4b0c0763.tar.gz
[Bug #19896]
fix memory leak in vm_method This introduces a unified reference_count to clarify who is referencing a method. This also allows us to treat the refinement method as the def owner since it counts itself as a reference Co-authored-by: Peter Zhu <peter@peterzhu.ca>
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index f98e6c6e75..9d3842ac75 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3811,7 +3811,7 @@ aliased_callable_method_entry(const rb_callable_method_entry_t *me)
VM_ASSERT(RB_TYPE_P(orig_me->owner, T_MODULE));
cme = rb_method_entry_complement_defined_class(orig_me, me->called_id, defined_class);
- if (me->def->alias_count + me->def->complemented_count == 0) {
+ if (me->def->reference_count == 1) {
RB_OBJ_WRITE(me, &me->def->body.alias.original_me, cme);
}
else {