String#encode() with no Encoding.default_internal returns a String with a 
shared buffer
---------------------------------------------------------------------------------------

                 Key: JRUBY-4304
                 URL: http://jira.codehaus.org/browse/JRUBY-4304
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules, Ruby 1.9
    Affects Versions: JRuby 1.4
            Reporter: Daniel Luz
         Attachments: 
0001-1.9-Fixed-String-encode-returning-a-String-with-a-sh.patch, 
0002-1.9-Fixed-various-forms-of-String-encode-using-share.patch

When Encoding.default_internal is nil, String#encode() (no-args version) 
returns a String which shares the same ByteBuffer, but without notifying the 

Simple testcase:

$ ruby1.9 -e 'foo="foo"; boo=foo.encode; boo[0]="b"; puts foo'
foo

$ jruby --1.9 -e 'foo="foo"; boo=foo.encode; boo[0]="b"; puts foo'
boo

Attached patch 0001 fixes this, by calling #dup rather than hand-building a 
duplicate.

Additionally, patch 0002 addresses the needless reuse of the buffer in other 
versions of String#encode. No harm is done here because the buffer is instantly 
replaced, but still there's no reason for that.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to