Skip to content
This repository was archived by the owner on Sep 22, 2021. It is now read-only.

Commit 4bb1a6d

Browse files
committed
Fix read-to-end bug
1 parent ef26cda commit 4bb1a6d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

DemoInfo/BitStream/UnsafeBitStream.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private void RefillBuffer()
107107
* as we overran the stream and wanna hit the throw above.
108108
*/
109109
Offset -= BitsInBuffer + 1;
110+
LazyGlobalPosition += BitsInBuffer + 1;
110111
*(uint*)PBuffer = 0; // safety
111112
BitsInBuffer = 0;
112113
continue;

Testing/TestBitstreams.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,28 @@ public void TestChunkNestingRandomExhaustive()
342342
}
343343
Assert.Fail("Should have thrown");
344344
}
345+
346+
[Test]
347+
public void TestStreamEndChunkBoundary()
348+
{
349+
dbgAll.BeginChunk(data.Length * 8);
350+
Assert.IsFalse(dbgAll.ChunkFinished);
351+
dbgAll.BeginChunk(data.Length * 8);
352+
Assert.IsFalse(dbgAll.ChunkFinished);
353+
dbgAll.EndChunk();
354+
Assert.IsTrue(dbgAll.ChunkFinished);
355+
dbgAll.EndChunk();
356+
}
357+
358+
[Test]
359+
public void TestStreamEndChunkBoundaryData()
360+
{
361+
dbgAll.BeginChunk(data.Length * 8);
362+
Assert.IsFalse(dbgAll.ChunkFinished);
363+
dbgAll.ReadBytes(data.Length);
364+
Assert.IsTrue(dbgAll.ChunkFinished);
365+
dbgAll.EndChunk();
366+
}
345367
}
346368
}
347369

0 commit comments

Comments
 (0)