From 42a096d455e0eaaa80f1344024df0d36c106de80 Mon Sep 17 00:00:00 2001 From: zii-dmg Date: Wed, 25 Jan 2023 01:15:00 +0300 Subject: [PATCH] Fixed dictionary null access (#276) Fixes #200 --- src/Zlib.Shared/Deflate.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Zlib.Shared/Deflate.cs b/src/Zlib.Shared/Deflate.cs index 9672250..9950b6a 100644 --- a/src/Zlib.Shared/Deflate.cs +++ b/src/Zlib.Shared/Deflate.cs @@ -1667,12 +1667,12 @@ internal int SetParams(CompressionLevel level, CompressionStrategy strategy) internal int SetDictionary(byte[] dictionary) { - int length = dictionary.Length; - int index = 0; - if (dictionary == null || status != INIT_STATE) throw new ZlibException("Stream error."); + int length = dictionary.Length; + int index = 0; + _codec._Adler32 = Adler.Adler32(_codec._Adler32, dictionary, 0, dictionary.Length); if (length < MIN_MATCH) @@ -1876,4 +1876,4 @@ internal int Deflate(FlushType flush) } } -} \ No newline at end of file +}