Skip to content

ArrayIndexOutOfBoundsException in parser #10

@pcy190

Description

@pcy190

The parser fails to throw the ParseException when the parser read the unclosed ', the following example input could cause the ArrayIndexOutOfBoundsException:

'c

In detail, when the parser tries to find closed single quotation mark using indexOf function, the iteration variable is not sets corretly in line 79:

protected int indexOf(char c, int pos) {
for (int i = pos; pos < len; i++)
if (in[i] == (byte) c)
return i;
return -1;
}

It shouldn't be the pos to be checked less than len. Instead, the i should be checked. The correct way in line 79 is:

for (int i = pos; i < len; i++) 

Any input with unclosed single quotation mark could trigger this. Like the input of 'c, cause the ArrayIndexOutOfBoundsException

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions