Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ protected <T> T readObject(JsonReaderI<T> mapper) throws ParseException, IOExcep
// should loop skipping read step
skipSpace();
if (c == '}') {
this.depth--;
read(); /* unstack */
//
return mapper.convert(current);
Expand Down
18 changes: 18 additions & 0 deletions json-smart/src/test/java/net/minidev/json/test/TestOverflow.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.minidev.json.test;

import net.minidev.json.JSONArray;
import net.minidev.json.JSONValue;
import net.minidev.json.parser.ParseException;

Expand Down Expand Up @@ -29,4 +30,21 @@ public void stressTest() throws Exception {
}
assertTrue(false);
}

@Test
public void shouldNotFailParsingArraysWith400Elements() throws Exception {
int size = 400;
StringBuilder sb = new StringBuilder();
sb.append("[");
for (int i=0; i < size; i++) {
sb.append("{a:true}");
if(i+1 < size) {
sb.append(",");
}
}
sb.append("]");
String s = sb.toString();
JSONArray array = (JSONArray) JSONValue.parseWithException(s);
assertEquals(array.size(), size);
}
}