diff --git a/tests/TdbIO.Tests/GzipTests.cs b/tests/TdbIO.Tests/GzipTests.cs index 54d8437..a0b650a 100644 --- a/tests/TdbIO.Tests/GzipTests.cs +++ b/tests/TdbIO.Tests/GzipTests.cs @@ -148,6 +148,16 @@ public void CorruptDeflateDataIsRejected() Rejects(file); } + [Fact] + public void LargeForgedIsizeWithCorruptDataDoesNotAllocateLargeBuffer() + { + byte[] file = Synthetic.Concat([0x1F, 0x8B, 0x08, 0x00, 0, 0, 0, 0, 0, 0], [0xFF, 0xFF, 0xFF], Synthetic.Le32(0u), Synthetic.Le32(64u * 1024 * 1024)); + long before = GC.GetTotalAllocatedBytes(precise: true); + Rejects(file); + long allocated = GC.GetTotalAllocatedBytes(precise: true) - before; + Assert.True(allocated < 4 * 1024 * 1024, $"Allocated {allocated} bytes, expected < 4 MiB"); + } + [Fact] public void PeekInflatesTheHeadOfCutData() {