summaryrefslogtreecommitdiff
path: root/encoding.c
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-06-28 16:04:49 -0400
committerGitHub <noreply@github.com>2024-06-28 16:04:49 -0400
commit291cc913503475a204c93a53a2f470c8cc6bfca2 (patch)
tree08e2f0fc52f61c6df20502e11e4f27f14b86482d /encoding.c
parent7a780a3ef766e0622ade4a5fbf2518f73c38282b (diff)
[Bug #20598] Fix corruption of internal encoding string (#11069)
Fix corruption of internal encoding string [Bug #20598] Just like [Bug #20595], Encoding#name_list and Encoding#aliases can have their strings corrupted when Encoding.default_internal is set to nil. Co-authored-by: Matthew Valentine-House <matt@eightbitraptor.com>
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/encoding.c b/encoding.c
index 383076f79b..3613fcc9f0 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1788,7 +1788,7 @@ static int
rb_enc_name_list_i(st_data_t name, st_data_t idx, st_data_t arg)
{
VALUE ary = (VALUE)arg;
- VALUE str = rb_fstring_cstr((char *)name);
+ VALUE str = rb_interned_str_cstr((char *)name);
rb_ary_push(ary, str);
return ST_CONTINUE;
}
@@ -1833,7 +1833,7 @@ rb_enc_aliases_enc_i(st_data_t name, st_data_t orig, st_data_t arg)
str = rb_fstring_cstr(rb_enc_name(enc));
rb_ary_store(ary, idx, str);
}
- key = rb_fstring_cstr((char *)name);
+ key = rb_interned_str_cstr((char *)name);
rb_hash_aset(aliases, key, str);
return ST_CONTINUE;
}