summaryrefslogtreecommitdiff
path: root/method.h
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-09-19 20:48:41 -0400
committerPeter Zhu <[email protected]>2023-09-20 10:19:24 -0400
commit96c5a4be7b0d72502001734770af0f4a735c544c (patch)
tree77ced0cc55236787ecf8fee4916936da55e54944 /method.h
parent3c11cdbcfe5ebcf430b0cdfefb0b92724eebe543 (diff)
Fix memory leak in complemented method entries
[Bug #19894] When a copy of a complemented method entry is created, there are two issues: 1. IMEMO_FL_USER3 is not copied, so the complemented status is not copied over. 2. In rb_method_entry_clone we increment both alias_count and complemented_count. However, when we free the method entry in rb_method_definition_release, we only decrement one of the two counters, resulting in the rb_method_definition_t being leaked. Co-authored-by: Adam Hess <[email protected]>
Diffstat (limited to 'method.h')
-rw-r--r--method.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/method.h b/method.h
index 6b60a49a3a..fbbcad075f 100644
--- a/method.h
+++ b/method.h
@@ -101,8 +101,9 @@ static inline void
METHOD_ENTRY_FLAGS_COPY(rb_method_entry_t *dst, const rb_method_entry_t *src)
{
dst->flags =
- (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2)) |
- (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2));
+ (dst->flags & ~(IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2
+ |IMEMO_FL_USER3)) |
+ (src->flags & (IMEMO_FL_USER0|IMEMO_FL_USER1|IMEMO_FL_USER2|IMEMO_FL_USER3));
}
typedef enum {