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

align C ported memsearch code - need to handle array[length] properly #5037

Merged
merged 1 commit into from
Feb 14, 2018

Conversation

kares
Copy link
Member

@kares kares commented Feb 8, 2018

... otherwise code doing utf8 str scan might fail with array-out-of-index

resolves GH-5036

someone with C knowledge please review, seems to me that MRI handles the case without special care :
at rb_memsearch_qs_utf8_hash(byte[] xBytes, final int x) while x == xBytes.length

... otherwise code doing utf8 str scan might fail with array-out-of-index

resolves GH-2036
@kares kares added this to the JRuby 9.1.16.0 milestone Feb 8, 2018
}
else {
h = '\0'; // (C) ary end - due y+m at rb_memsearch_qs_utf8
}
if (h < 0xC0) {
return h + 256;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will always return 256 at string end...is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep - should return the very same as the (original) C code when reaching \0 boundary

@kares kares merged commit 23f53d3 into jruby-9.1 Feb 14, 2018
@kares kares deleted the fix-2036-9.1 branch February 14, 2018 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants