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)
Minimal reproducible example:
import org.json.simple.JSONObject;
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)