oleg-st/ZstdSharp

DecompressionStream should be safe to Dispose twice

avl opened this issue · 2 comments

avl commented

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.

Thanks for reporting
I think it was introduced in #5

Fixed in #9