mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
Fixed NPE caused by lazily initializing BitInput
This commit is contained in:
parent
1868a8c089
commit
3e31869417
@ -40,11 +40,10 @@ public class ByteInput implements Aligned, AlignedReader {
|
||||
|
||||
@Override
|
||||
public boolean aligned() {
|
||||
return bitInput.aligned();
|
||||
return bitInput == null || bitInput.aligned();
|
||||
}
|
||||
|
||||
public BitInput unalign() {
|
||||
// FIXME: should bitInput.bitsRead = (long) bytesRead * Byte.SIZE
|
||||
if (bitInput == null) this.bitInput = new BitInput(this);
|
||||
return bitInput;
|
||||
}
|
||||
@ -116,11 +115,13 @@ public class ByteInput implements Aligned, AlignedReader {
|
||||
|
||||
long incrementBitsRead(long bits) {
|
||||
assert (bits & (Byte.SIZE - 1)) == 0;
|
||||
if (bitInput == null) return 0;
|
||||
return bitInput.incrementBitsRead(bits);
|
||||
}
|
||||
|
||||
long decrementBitsRead(long bits) {
|
||||
assert (bits & (Byte.SIZE - 1)) == 0;
|
||||
if (bitInput == null) return 0;
|
||||
return bitInput.decrementBitsRead(bits);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user