Skip to content

Commit

Permalink
Wrap possible AssertionError from Ion class (#418)
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan authored Dec 6, 2023
1 parent 0e76830 commit be8d29e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,11 @@ public String getText() throws IOException
try {
// stringValue() will throw an UnknownSymbolException if we're
// trying to get the text for a symbol id that cannot be resolved.
// stringValue() has an assert statement which could throw an
// AssertionError if we're trying to get the text with a symbol
// id less than or equals to 0.
return _reader.stringValue();
} catch (UnknownSymbolException e) {
} catch (UnknownSymbolException | AssertionError e) {
throw _constructError(e.getMessage(), e);
}
case VALUE_NUMBER_INT:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.fasterxml.jackson.dataformat.ion.fuzz;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.dataformat.ion.*;

import java.io.IOException;

import org.junit.Assert;
import org.junit.Test;

@SuppressWarnings("resource")
public class Fuzz64721InvalidIonTest
{
@Test(expected = JsonParseException.class)
public void testFuzz64721AssertionException() throws IOException {
IonFactory f = IonFactory
.builderForBinaryWriters()
.enable(IonParser.Feature.USE_NATIVE_TYPE_ID)
.build();
IonObjectMapper mapper = IonObjectMapper.builder(f).build();
mapper.readValue("$0/", EnumFuzz.class);
}

private static enum EnumFuzz {
A, B, C, D, E;
}
}

0 comments on commit be8d29e

Please sign in to comment.