PSeitz / lz4_flex

Fastest pure Rust implementation of LZ4 compression/decompression.
MIT License
441 stars 28 forks source link

Small ext_dict leads to panic #93

Closed codertao closed 5 months ago

codertao commented 1 year ago

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.

PSeitz commented 1 year ago

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.