Skip to content

Encoding::Converter#primitive_convert has trailing null byte #2764

@nirvdrum

Description

@nirvdrum

Encoding::Converter#primitive_convert seems to have a trailing null byte. More accurately, the ByteList end pointer seems to be off by one.

str = "あいうえお"
dst = ""
ec = Encoding::Converter.new str.encoding, Encoding::ISO_2022_JP, 0
ec.primitive_convert str.dup, dst, nil, nil, 0
p dst 0

MRI 2.2.1:

> ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

> ruby yo.rb 
"\e\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2A\e\x28\x42"

JRuby 9k:

> bin/jruby -v
jruby 9.0.0.0-SNAPSHOT (2.2.1) 2015-03-26 20c6a62 Java HotSpot(TM) 64-Bit Server VM 24.76-b04 on 1.7.0_76-b13 +jit [linux-amd64]

> bin/jruby yo.rb 
"\e\x24\x42\x24\x22\x24\x24\x24\x26\x24\x28\x24\x2A\e\x28\x42\x00"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions