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

@atambo
Copy link
Member

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

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
String#rindex should handle matchdata strings
@enebo enebo merged commit 5a36c57 into jruby:jruby-1_7 Jun 14, 2014
1 check failed
1 check failed
@atambo
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
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants