-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
When the string provided to StringScanner.new is represented by a ByteList with a non-zero begin offset, the length for new strings is calculated incorrectly (length and begin get added together). No tests exist for this case, which typically happens when the source string has itself been sliced off the end of a larger string and still shares the same buffer.
$ jruby -rstrscan -e 'str = "hellohello"[5..-1]; StringScanner.new(str).scan(/hello/)'
Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 15 out of bounds for byte[10]
java.lang.ArrayIndexOutOfBoundsException: arraycopy: last source index 15 out of bounds for byte[10]
arraycopy at java/lang/System.java:-2
<init> at org/jruby/util/ByteList.java:227
newString at org/jruby/ext/strscan/RubyStringScanner.java:877
extractBegLen at org/jruby/ext/strscan/RubyStringScanner.java:260
scan at org/jruby/ext/strscan/RubyStringScanner.java:342
scan at org/jruby/ext/strscan/RubyStringScanner.java:391
This is the cause of jruby/jruby#8083. FIx coming.
Metadata
Metadata
Assignees
Labels
No labels