-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
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:
json-smart-v1/json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java
Lines 78 to 83 in 4e6596f
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