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

Bug: StackOverflow in toString() (infinite recursion) #148

Open
kmnls opened this issue Sep 16, 2022 · 0 comments
Open

Bug: StackOverflow in toString() (infinite recursion) #148

kmnls opened this issue Sep 16, 2022 · 0 comments

Comments

@kmnls
Copy link

kmnls commented Sep 16, 2022

Minimal reproducible example:

import org.json.simple.JSONObject;

public class Test {
    public static void main(String[] args) throws Exception {

        JSONObject obj1=new JSONObject();
        obj1.put("",obj1);
        obj1.toString();
     }
}

Description:

Converting invalid JSONObject to String will result in stack overflow.

Log:

Exception in thread "main" java.lang.StackOverflowError
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:55)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:74)
at org.json.simple.JSONValue.writeJSONString(JSONValue.java:160)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:68)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:74)
at org.json.simple.JSONValue.writeJSONString(JSONValue.java:160)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:68)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:74)
at org.json.simple.JSONValue.writeJSONString(JSONValue.java:160)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:68)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:74)
at org.json.simple.JSONValue.writeJSONString(JSONValue.java:160)
at org.json.simple.JSONObject.writeJSONString(JSONObject.java:68)

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