oleg-st / ZstdSharp

Port of zstd compression library to c#
MIT License
200 stars 29 forks source link

DecompressionStream should be safe to Dispose twice #8

Closed avl closed 1 year ago

avl commented 1 year ago

The DecompressionStream's Dispose-method calls ArrayPool<byte>.Shared.Return(this.inputBuffer); each time it is called.

According to the documentation for the IDisposable interface, "the object must ignore all calls after the first one".

As it is now, calling Dispose multiple times on DecompressionStream, corrupts the shared (global) ArrayPool.

The Dispose-method should be modified so that it does not return inputBuffer to the array pool more than once.

oleg-st commented 1 year ago

Thanks for reporting I think it was introduced in #5

oleg-st commented 1 year ago

Fixed in #9