diff --git a/src/SharpCompress/Algorithms/Alder32.cs b/src/SharpCompress/Algorithms/Alder32.cs
index 5faf1597..9a353993 100644
--- a/src/SharpCompress/Algorithms/Alder32.cs
+++ b/src/SharpCompress/Algorithms/Alder32.cs
@@ -51,11 +51,6 @@ namespace SharpCompress.Algorithms
/// The .
public static uint Calculate(uint adler, ReadOnlySpan buffer)
{
- if (buffer.IsEmpty)
- {
- return SeedValue;
- }
-
#if !NETSTANDARD2_0 && !NETSTANDARD2_1 && !NETFRAMEWORK
if (Sse3.IsSupported && buffer.Length >= MinBufferSize)
{
diff --git a/src/SharpCompress/SharpCompress.csproj b/src/SharpCompress/SharpCompress.csproj
index 3686b111..9dc1ee19 100644
--- a/src/SharpCompress/SharpCompress.csproj
+++ b/src/SharpCompress/SharpCompress.csproj
@@ -2,9 +2,9 @@
SharpCompress - Pure C# Decompression/Compression
en-US
- 0.30.0
- 0.30.0
- 0.30.0
+ 0.30.1
+ 0.30.1
+ 0.30.1
Adam Hathcock
net461;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0
true
diff --git a/tests/SharpCompress.Test/SharpCompress.Test.csproj b/tests/SharpCompress.Test/SharpCompress.Test.csproj
index b57ed357..de801011 100644
--- a/tests/SharpCompress.Test/SharpCompress.Test.csproj
+++ b/tests/SharpCompress.Test/SharpCompress.Test.csproj
@@ -12,8 +12,9 @@
+
-
+
diff --git a/tests/SharpCompress.Test/Streams/ZlibBaseStreamTests.cs b/tests/SharpCompress.Test/Streams/ZlibBaseStreamTests.cs
index 450a33be..dd8f8943 100644
--- a/tests/SharpCompress.Test/Streams/ZlibBaseStreamTests.cs
+++ b/tests/SharpCompress.Test/Streams/ZlibBaseStreamTests.cs
@@ -1,6 +1,9 @@
using System.IO;
+using System.Text;
+using FluentAssertions;
using SharpCompress.Compressors;
using SharpCompress.Compressors.Deflate;
+using SharpCompress.IO;
using Xunit;
namespace SharpCompress.Test.Streams
@@ -31,5 +34,55 @@ namespace SharpCompress.Test.Streams
Assert.Equal(total, realCompressedSize);
}
+
+ [Fact]
+ public void Zlib_should_read_the_previously_written_message()
+ {
+ var message = new string('a', 131073); // 131073 causes the failure, but 131072 (-1) doesn't
+ var bytes = Encoding.ASCII.GetBytes(message);
+
+ using (var inputStream = new MemoryStream(bytes))
+ {
+ using (var compressedStream = new MemoryStream())
+ using (var byteBufferStream = new BufferedStream(inputStream)) // System.IO
+ {
+ Compress(byteBufferStream, compressedStream, compressionLevel: 1);
+ compressedStream.Position = 0;
+
+ using (var decompressedStream = new MemoryStream())
+ {
+ Decompress(compressedStream, decompressedStream);
+
+ byteBufferStream.Position = 0;
+ var result = Encoding.ASCII.GetString(GetBytes(byteBufferStream));
+ result.Should().Be(message);
+ }
+ }
+ }
+ }
+
+ public void Compress(Stream input, Stream output, int compressionLevel)
+ {
+ using (var zlibStream = new ZlibStream(new NonDisposingStream(output), CompressionMode.Compress, (CompressionLevel)compressionLevel))
+ {
+ zlibStream.FlushMode = FlushType.Sync;
+ input.CopyTo(zlibStream);
+ }
+ }
+
+ public void Decompress(Stream input, Stream output)
+ {
+ using (var zlibStream = new ZlibStream(new NonDisposingStream(input), CompressionMode.Decompress))
+ {
+ zlibStream.CopyTo(output);
+ }
+ }
+
+ byte[] GetBytes(BufferedStream stream)
+ {
+ byte[] bytes = new byte[stream.Length];
+ stream.Read(bytes, 0, (int)stream.Length);
+ return bytes;
+ }
}
}