[Bug #22322] Take transcoder names from declared transcoders

Fix use-after-free of dangling pointers.
This commit is contained in:
Nobuyoshi Nakada authored and Nobuyoshi Nakada committed 2026-09-16 20:27:27 +09:00
1 parent 226f37012d
commit 20ca4e1f64
2 files changed
+16
Notes: git 2026-09-16 11:28:01 +00:00

No files matched your search

+14
View File
@@ -856,6 +856,20 @@ class TestEncodingConverter < Test::Unit::TestCase
"\222\xA1x".encode("iso-2022-jp", "stateless-iso-2022-jp", :invalid => :replace))
end
def test_inspect_decorator_source_name
decorator_names = %w[
amp_escape xml_text_escape xml_attr_content_escape xml_attr_quote
universal_newline crlf_newline cr_newline lf_newline
]
all_assertions_foreach(nil, *decorator_names) do |decorator|
ec = Encoding::Converter.new('', decorator)
inspect = ec.inspect
10_000.times {"A"*100}
GC.start(full_mark: true, immediate_sweep: true)
assert_equal inspect, ec.inspect
end
end
def test_convpath
eucjp = Encoding::EUC_JP
utf8 = Encoding::UTF_8
+2
View File
@@ -1045,6 +1045,8 @@ rb_econv_open0(const char *sname, const char *dname, int ecflags)
SIZED_FREE_N(entries, num_trans);
return NULL;
}
sname = entries[0]->sname;
dname = entries[num_trans-1]->dname;
}
ec = rb_econv_open_by_transcoder_entries(num_trans, entries);