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;