ArrayIndexOutOfBoundsException in RubyString#justify
----------------------------------------------------

                 Key: JRUBY-1154
                 URL: http://jira.codehaus.org/browse/JRUBY-1154
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.0.0RC3, JRuby 1.0.0
            Reporter: Ronny Voelker
         Attachments: trunk.patch

String#ljust or String#center throws an ArrayIndexOutOfBoundsException in 
RubyString#justify, if the string is a part of another string.

Example:
irb(main):001:0> x = "abab"[2..3]
=> "ab"
irb(main):002:0> x.rjust(4)
=> "  ab"
irb(main):003:0> x.ljust(4)
NativeException: java.lang.ArrayIndexOutOfBoundsException: 4
        from RubyString.java:2701:in `org.jruby.RubyString.justify'
...

Reason:
The end value of the iterator variable of the iteration which fills up the 
ByteArray of the resulting string is calculated too high.
The begin of the source ByteArray is used for calculating the length of the 
resulting ByteArray, instead of the begin of the resulting ByteArray.

A Patch for the trunk is attached.

-- 
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