Cysharp / MemoryPack

Zero encoding extreme performance binary serializer for C# and Unity.
MIT License
3.01k stars 182 forks source link

Infinite loop in BrotliEncoder #279

Closed kimk-s closed 3 months ago

kimk-s commented 3 months ago

Hello!

It seems like an infinite loop is occurring in BrotliCompressor while my program is running. I can't reproduce this exactly, but I did my best. If you don't mind, I would appreciate it if you could check the code below.

Used MemoryPack version: 1.21.0

var buffer = new ArrayBufferWriter<byte>(256);
using var state = MemoryPackWriterOptionalStatePool.Rent(null);
var writer = new MemoryPackWriter<ArrayBufferWriter<byte>>(ref buffer, state);

var compressor = new BrotliCompressor();
var coWriter = new MemoryPackWriter<BrotliCompressor>(ref compressor, writer.OptionalState);

var bytes = new byte[249];
Random.Shared.NextBytes(bytes);
coWriter.WriteUnmanagedArray(bytes);
coWriter.Flush();

compressor.CopyTo(ref writer);
neuecc commented 3 months ago

thanks for the report, I'll check soon.

neuecc commented 3 months ago

Thanks, I've fixed at v1.21.1.