Skip to content

Commit be8d29e

Browse files
authored
Wrap possible AssertionError from Ion class (#418)
Signed-off-by: Arthur Chan <arthur.chan@adalogics.com>
1 parent 0e76830 commit be8d29e

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,11 @@ public String getText() throws IOException
274274
try {
275275
// stringValue() will throw an UnknownSymbolException if we're
276276
// trying to get the text for a symbol id that cannot be resolved.
277+
// stringValue() has an assert statement which could throw an
278+
// AssertionError if we're trying to get the text with a symbol
279+
// id less than or equals to 0.
277280
return _reader.stringValue();
278-
} catch (UnknownSymbolException e) {
281+
} catch (UnknownSymbolException | AssertionError e) {
279282
throw _constructError(e.getMessage(), e);
280283
}
281284
case VALUE_NUMBER_INT:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.fasterxml.jackson.dataformat.ion.fuzz;
2+
3+
import com.fasterxml.jackson.core.JsonParseException;
4+
import com.fasterxml.jackson.dataformat.ion.*;
5+
6+
import java.io.IOException;
7+
8+
import org.junit.Assert;
9+
import org.junit.Test;
10+
11+
@SuppressWarnings("resource")
12+
public class Fuzz64721InvalidIonTest
13+
{
14+
@Test(expected = JsonParseException.class)
15+
public void testFuzz64721AssertionException() throws IOException {
16+
IonFactory f = IonFactory
17+
.builderForBinaryWriters()
18+
.enable(IonParser.Feature.USE_NATIVE_TYPE_ID)
19+
.build();
20+
IonObjectMapper mapper = IonObjectMapper.builder(f).build();
21+
mapper.readValue("$0/", EnumFuzz.class);
22+
}
23+
24+
private static enum EnumFuzz {
25+
A, B, C, D, E;
26+
}
27+
}

0 commit comments

Comments
 (0)