Skip to content

Commit 7e1e0e6

Browse files
authored
Merge pull request #2836 from ksss/fix-gc-compact
Fix for string reference corruption issue
2 parents 482b1d7 + d533fa7 commit 7e1e0e6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/rbs_extension/main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ static void declare_type_variables(rbs_parser_t *parser, VALUE variables, VALUE
6767
}
6868

6969
VALUE name_str = rb_sym2str(symbol);
70+
uint8_t *copied_name = (uint8_t *) malloc((size_t) RSTRING_LEN(name_str));
71+
memcpy((void *) copied_name, RSTRING_PTR(name_str), RSTRING_LEN(name_str));
7072

71-
rbs_constant_id_t id = rbs_constant_pool_insert_shared(
73+
rbs_constant_id_t id = rbs_constant_pool_insert_owned(
7274
&parser->constant_pool,
73-
(const uint8_t *) RSTRING_PTR(name_str),
75+
copied_name,
7476
RSTRING_LEN(name_str)
7577
);
7678

0 commit comments

Comments
 (0)