Rhea.Compression icon indicating copy to clipboard operation
Rhea.Compression copied to clipboard

Compressed string consisting of only "X" fails to decompress

Open redoz opened this issue 9 years ago • 1 comments

var text = new string('X', 1000);
var compressDebug = compressionHandler.CompressDebug(text);
var d = compressionHandler.DecompressDebug(compressDebug); // throws IndexOutOfRangeException on line 73 in SubstringUnpacker

redoz avatar Jun 15 '16 14:06 redoz

seem a quick & dirty fix is to change it to:

                var bytes = buffer.GetBuffer();
                for (int i = 0; i < length; i++)
                {
                    // if buffer was resized, get the new one
                    if (this.buffer.Capacity > bytes.Length)
                        bytes = buffer.GetBuffer();

                    buffer.WriteByte(bytes[i + currentIndex + offset]);
                }

redoz avatar Jun 15 '16 15:06 redoz