Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String#rindex should handle matchdata strings #1714

Merged
merged 1 commit into from Jun 14, 2014

Conversation

Projects
None yet
2 participants
@atambo
Copy link
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

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

enebo added a commit that referenced this pull request Jun 14, 2014

Merge pull request #1714 from atambo/rindex_with_matchdata
String#rindex should handle matchdata strings

@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
You can’t perform that action at this time.