Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensures that the cursor's value marker is fully reset between values. #787

Merged
merged 1 commit into from
Apr 12, 2024
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
Loading