Skip to content

Commit 3740a93

Browse files
committed
Add test for #736
1 parent 18b4634 commit 3740a93

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.core.*;
4+
import com.fasterxml.jackson.core.exc.StreamReadException;
5+
6+
public class JsonPointerOOME736Test extends BaseTest
7+
{
8+
// such as https://github.com/nst/JSONTestSuite/blob/master/test_parsing/n_structure_100000_opening_arrays.json
9+
public void testDeepJsonPointer() throws Exception {
10+
int MAX_DEPTH = 100000;
11+
String INPUT = new String(new char[MAX_DEPTH]).replace("\0", "[");
12+
JsonParser parser = createParser(MODE_READER, INPUT);
13+
try {
14+
while (true) {
15+
parser.nextToken();
16+
}
17+
} catch (StreamReadException e) {
18+
verifyException(e, "Unexpected end");
19+
JsonStreamContext parsingContext = parser.getParsingContext();
20+
JsonPointer jsonPointer = parsingContext.pathAsPointer(); // OOME
21+
String pointer = jsonPointer.toString();
22+
String expected = new String(new char[MAX_DEPTH - 1]).replace("\0", "/0");
23+
assertEquals(expected, pointer);
24+
}
25+
parser.close();
26+
}
27+
}

0 commit comments

Comments
 (0)