From 506773d25c66650a72ce5d111141c8785a4fdb85 Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sun, 16 Aug 2020 02:33:47 -0700 Subject: [PATCH] Added missing assertions --- core/src/com/riiablo/io/ByteInput.java | 1 + core/src/com/riiablo/io/ByteOutput.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/core/src/com/riiablo/io/ByteInput.java b/core/src/com/riiablo/io/ByteInput.java index 8cb8df21..f073b1cb 100644 --- a/core/src/com/riiablo/io/ByteInput.java +++ b/core/src/com/riiablo/io/ByteInput.java @@ -217,6 +217,7 @@ public class ByteInput { * @see ByteBuf#readSlice(int) */ public ByteInput readSlice(long numBytes) { + assert aligned() : "not aligned"; assert numBytes <= Integer.MAX_VALUE : "ByteBuf only supports int length"; final int mark = updateMark(); // updates mark to start offset of slice final ByteBuf slice = buffer.readSlice((int) numBytes); diff --git a/core/src/com/riiablo/io/ByteOutput.java b/core/src/com/riiablo/io/ByteOutput.java index 08b5ced7..60c8ccc5 100644 --- a/core/src/com/riiablo/io/ByteOutput.java +++ b/core/src/com/riiablo/io/ByteOutput.java @@ -51,6 +51,7 @@ public class ByteOutput { } public ByteOutput skipBytes(int bytes) { + assert aligned() : "not aligned"; incrementBitsWritten((long) bytes * Byte.SIZE); buffer.writeZero(bytes); return this; @@ -108,6 +109,7 @@ public class ByteOutput { } public ByteOutput writeString(CharSequence chars) { + assert aligned() : "not aligned"; incrementBitsWritten((long) chars.length() * Byte.SIZE); buffer.writeCharSequence(chars, CharsetUtil.US_ASCII); return this;