Skip to content

CharSeqAdapter.toString throws StringIndexOutOfBoundsException #7

Description

@yurijvolkov

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions