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

CharSeqAdapter.toString throws StringIndexOutOfBoundsException #7

Open
yurijvolkov opened this issue Apr 8, 2018 · 0 comments
Open

Comments

@yurijvolkov
Copy link

While exploring DictionaryBase.weightedParse() I found that after second iteration of inner for-loop ( DictionaryBase.java:148). suffix.toString() starts throwing StringIndexOutOfBoundsException.
You can make sure of that by inserting String s = suffix.toString(); after DictionaryBase.java:149 line. After that test DictExpansionTest.testIndependent() will fail.

After tiny exploration I found that it's happening because of bug(?) in CharSeqAdapter.copyToArray().
Does line start += this.start; make sense? In function CharSeqAdapter.charAt() we also do that operation. So we incrementing offset twice.
Because of that while incrementing start in for-loop in CharSeq.copyToArray() it goes out of the bound of initial delegate size.

I will provide a pull request if this would be confirmed.

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

No branches or pull requests

1 participant