|
1 | 1 | // Copyright (c) Six Labors. |
2 | 2 | // Licensed under the Six Labors Split License. |
3 | | -#nullable disable |
4 | 3 |
|
5 | 4 | using System.Buffers; |
6 | 5 | using System.Runtime.CompilerServices; |
@@ -87,7 +86,7 @@ internal sealed unsafe class DeflaterEngine : IDisposable |
87 | 86 | /// <summary> |
88 | 87 | /// The input data for compression. |
89 | 88 | /// </summary> |
90 | | - private byte[] inputBuf; |
| 89 | + private byte[]? inputBuf; |
91 | 90 |
|
92 | 91 | /// <summary> |
93 | 92 | /// The offset into inputBuf, where input data starts. |
@@ -222,7 +221,7 @@ public bool Deflate(bool flush, bool finish) |
222 | 221 | /// <param name="buffer">The buffer containing input data.</param> |
223 | 222 | /// <param name="offset">The offset of the first byte of data.</param> |
224 | 223 | /// <param name="count">The number of bytes of data to use as input.</param> |
225 | | - public void SetInput(byte[] buffer, int offset, int count) |
| 224 | + public void SetInput(byte[]? buffer, int offset, int count) |
226 | 225 | { |
227 | 226 | if (buffer is null) |
228 | 227 | { |
@@ -362,6 +361,8 @@ public void FillWindow() |
362 | 361 | more = this.inputEnd - this.inputOff; |
363 | 362 | } |
364 | 363 |
|
| 364 | + ArgumentNullException.ThrowIfNull(this.inputBuf); |
| 365 | + |
365 | 366 | Unsafe.CopyBlockUnaligned( |
366 | 367 | ref this.window.Span[this.strstart + this.lookahead], |
367 | 368 | ref this.inputBuf[this.inputOff], |
@@ -393,11 +394,6 @@ public void Dispose() |
393 | 394 | this.prevMemoryHandle.Dispose(); |
394 | 395 | this.prevMemoryOwner.Dispose(); |
395 | 396 |
|
396 | | - this.windowMemoryOwner = null; |
397 | | - this.headMemoryOwner = null; |
398 | | - this.prevMemoryOwner = null; |
399 | | - this.huffman = null; |
400 | | - |
401 | 397 | this.isDisposed = true; |
402 | 398 | } |
403 | 399 | } |
|
0 commit comments