From 40b8490fa4c0fc46783ff0d6baf68d251a5cd22b Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Wed, 1 Jan 2020 19:14:46 +0900 Subject: Revert "SHARED string is not required when sharing POOL string" (75949836) Because literal pool may be released by GC. #### Example: ```ruby s1 = eval('"abcdefghijklmnopqrstuvwxyz01"') GC.start p s1 #=> "\x00\x00\x00\x00\x00\x00\x00\x90\x00\x00\x00\x00\x00\x00\x00\x90\x03\x00stuvwxyz01" ``` --- src/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/string.c b/src/string.c index b3f07dfb0..8141019b6 100644 --- a/src/string.c +++ b/src/string.c @@ -553,7 +553,7 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s) size_t len = (size_t)orig->as.heap.len; mrb_assert(!RSTR_EMBED_P(orig)); - if (RSTR_NOFREE_P(orig) || RSTR_POOL_P(orig)) { + if (RSTR_NOFREE_P(orig)) { str_init_nofree(s, orig->as.heap.ptr, len); } else if (RSTR_SHARED_P(orig)) { @@ -562,7 +562,7 @@ str_share(mrb_state *mrb, struct RString *orig, struct RString *s) else if (RSTR_FSHARED_P(orig)) { str_init_fshared(orig, s, orig->as.heap.aux.fshared); } - else if (mrb_frozen_p(orig)) { + else if (mrb_frozen_p(orig) && !RSTR_POOL_P(orig)) { str_init_fshared(orig, s, orig); } else { -- cgit v1.2.3