Skip to content

Commit feb61fd

Browse files
committed
close(): ensure that all calls to readBitsInt*() fail after closing
1 parent c984261 commit feb61fd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/main/java/io/kaitai/struct/ByteBufferKaitaiStream.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public void close() throws IOException {
172172
try {
173173
if (bitsWriteMode) {
174174
writeAlignToByte();
175+
} else {
176+
alignToByte();
175177
}
176178
} catch (Exception e) {
177179
exc = e;

src/main/java/io/kaitai/struct/RandomAccessFileKaitaiStream.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ public void close() throws IOException {
6060
try {
6161
if (bitsWriteMode) {
6262
writeAlignToByte();
63+
} else {
64+
alignToByte();
6365
}
6466
} catch (Exception e) {
6567
exc = e;
6668
throw e;
6769
} finally {
68-
alignToByte();
6970
try {
7071
raf.close();
7172
} catch (IOException e) {

0 commit comments

Comments
 (0)