Actions
Bug #20189
open`rb_str_resize` does not clear coderange when expanding
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0dev (2024-01-09T07:07:19Z master db476cc71c) [x86_64-linux]
Description
Expanding string in some encoding (utf16 utf32) can change coderange to either valid or broken, but rb_str_resize does not clear coderange.
This will cause a bug in c-extension libraries that use rb_str_resize.
# Example for stringio
s = StringIO.new("\0".encode('UTF-16LE'))
s.truncate(1); s.truncate(2); s.string.valid_encoding?
#=> true
s.truncate(1); s.string.valid_encoding?; s.truncate(2); s.string.valid_encoding?
#=> false (expect to be true)
Actions
Like0
Like0Like0Like0Like0Like0Like0