Skip to content

Init a JSONArray with "[" will induce StackOverflowError in version 20171018. #388

@yaosiang

Description

@yaosiang

When I upgrade org.json from 20170516 to 20171018, my unit test begin to failed, the test case shows if I init a JSONArray with "[", it will induce StackOverflowError.

new JSONArray("[");

The call stack shows a infinite loop between JSONTokener.nextValue and JSONArray.<init>

Exception in thread "main" java.lang.StackOverflowError
	at org.json.JSONTokener.back(JSONTokener.java:109)
	at org.json.JSONTokener.nextValue(JSONTokener.java:433)
	at org.json.JSONArray.<init>(JSONArray.java:118)
	at org.json.JSONTokener.nextValue(JSONTokener.java:434)
	at org.json.JSONArray.<init>(JSONArray.java:118)
	at org.json.JSONTokener.nextValue(JSONTokener.java:434)
	at org.json.JSONArray.<init>(JSONArray.java:118)
	at org.json.JSONTokener.nextValue(JSONTokener.java:434)
	at org.json.JSONArray.<init>(JSONArray.java:118)
	at org.json.JSONTokener.nextValue(JSONTokener.java:434)
	at org.json.JSONArray.<init>(JSONArray.java:118)
        ... skip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions