lz4_flex icon indicating copy to clipboard operation
lz4_flex copied to clipboard

Small ext_dict leads to panic

Open codertao opened this issue 2 years ago • 1 comments

Calling block::compress::compress_into_with_dict, with a dict of length of 1,2, or 3 results in a panic at

thread 'block::compress_slow::tests::test_all_the_stuff' panicked at 'range end index 4 out of range for slice of length 3', src/block/compress.rs:43:24
...
lz4_flex::block::compress::get_batch
             at ./src/block/compress.rs:43:24

I ran into this during testing for new functionality I needed- adding a no-hash-table compressor for use in embedded/memory constrained environments. I removed the offending tests / this isn't affecting me, but it's probably still worth reporting.

codertao avatar Feb 26 '23 11:02 codertao

Thanks for the report. The minimum match length is 4, a dict smaller than that cannot have matches. It shouldn't panic though and ignore the dict instead.

PSeitz avatar Feb 26 '23 13:02 PSeitz