diff options
| author | nagachika <nagachika@ruby-lang.org> | 2023-09-24 15:13:32 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-09-24 15:13:32 +0900 |
| commit | 9ee58b2054c1bbe722ae5a2a4ec6a750ee583220 (patch) | |
| tree | 448b91bbf2b07702f8e61756f9d6ed050be63dc8 /method.h | |
| parent | 9cd28caa7cc3b0d987db7c1231fe101fb3b27399 (diff) | |
merge revision(s) 96c5a4be7b0d72502001734770af0f4a735c544c: [Backport #19894]
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 <adamhess1991@gmail.com>
---
method.h | 5 +++--
test/ruby/test_module.rb | 29 +++++++++++++++++++++++++++++
vm_method.c | 8 +++++---
3 files changed, 37 insertions(+), 5 deletions(-)
Diffstat (limited to 'method.h')
| -rw-r--r-- | method.h | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 { |
