Skip to content

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

Merged
kares merged 1 commit intojruby-9.1from
fix-2036-9.1
Feb 14, 2018
Merged

align C ported memsearch code - need to handle array[length] properly#5037
kares merged 1 commit intojruby-9.1from
fix-2036-9.1

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
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.

2 participants