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
1 change: 1 addition & 0 deletions src/main/java/com/amazon/ion/impl/IonCursorBinary.java
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ private boolean checkContainerEnd() {
* Resets state specific to the current value.
*/
private void reset() {
valueMarker.typeId = null;
valueMarker.startIndex = -1;
valueMarker.endIndex = -1;
fieldSid = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3933,6 +3933,25 @@ public void annotationSequenceLengthThatOverflowsBufferThrowsIonException(boolea
);
}

@ParameterizedTest(name = "constructFromBytes={0}")
@ValueSource(booleans = {true, false})
public void incompleteAnnotationAfterStructFailsCleanly(boolean constructFromBytes) throws Exception {
expectIonException(
constructFromBytes,
reader -> {
try {
assertEquals(IonType.STRUCT, reader.next());
} catch (Exception e) {
fail();
}
// This should fail with IonException due to unexpected EOF.
reader.next();
},
0xDF, // null.struct
0xE6, 0x81 // Incomplete annotation wrapper declaring length 6
);
}

/**
* Verifies that corrupting each byte in the input data results in IonException, or nothing.
* @param constructFromBytes whether to provide bytes (true) or an InputStream (false) to the reader.
Expand Down