Skip to content

Commit f34e954

Browse files
committed
Fix ReadBits not aligning its output like the SDK
1 parent 339564c commit f34e954

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎Source.Common/Bitbuffers/bf_read.cs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ public void ReadBits(Span<byte> pOutData, int nBits) {
144144
byte* pOut = pOutRO;
145145
int nBitsLeft = nBits;
146146

147+
while (((nint)pOut & 3) != 0 && nBitsLeft >= 8) {
148+
*pOut = (byte)ReadUBitLong(8);
149+
++pOut;
150+
nBitsLeft -= 8;
151+
}
152+
147153
// read dwords
148154
while (nBitsLeft >= 32) {
149155
*(uint*)pOut = ReadUBitLong(32);

0 commit comments

Comments
 (0)