String#rindex should handle matchdata strings #1714

Merged
merged 1 commit into from Jun 14, 2014

Projects

None yet

2 participants

@atambo
Member
atambo commented May 24, 2014

A string extracted from a matchdata object shares the same
byte array as the string it was matched against. When doing a
rindex between a string from a matchdata and the string the matchdata
was matched against the same byte array is passed into ByteList.memcmp
which will always return 0 as ByteList.memcmp just checks for equality
of the byte arrays.

I fix this by passing bytes() instead getUnsafeBytes() into the
ByteList.memcmp method so that the byte arrays are different.

Fixes #1688

@atambo atambo String#rindex should handle matchdata strings
A string extracted from a matchdata object shares the same
byte array as the string it was matched against. When doing a
rindex between a string from a matchdata and the string the matchdata
was matched against the same byte array is passed into ByteList.memcmp
which will always return 0 as ByteList.memcmp just checks for equality
of the byte arrays.

I fix this by passing bytes() instead getUnsafeBytes() into the
ByteList.memcmp method so that the byte arrays are different.

Fixes #1688
5303e9a
@enebo enebo merged commit 5a36c57 into jruby:jruby-1_7 Jun 14, 2014

1 check failed

continuous-integration/travis-ci The Travis CI build failed
Details
@enebo enebo added this to the JRuby 1.7.13 milestone Jun 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment