fix: Handle exactly-sized buffers in compress_into/decompress_into#165
Conversation
|
One thing to call out here: an alternative approach would be for |
This is documented already in We just don't have a great way to enforce that before we start decoding, hence the assertion. If we no longer require that, we should update the doc comment. Have you run any of the decoding benchmarks to see if the |
Merging this PR will not alter performance
Comparing Footnotes
|
|
Seems like CodSpeed is convinced :D |
a10y
left a comment
There was a problem hiding this comment.
just fix the lints and gtg!
|
@stuhood would you mind fixing the lint so we can get this merged? |
## 🤖 New release * `fsst-rs`: 0.5.6 -> 0.5.7 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.5.7](v0.5.6...v0.5.7) - 2026-03-17 ### Fixed - Handle exactly-sized buffers in `compress_into`/`decompress_into` ([#165](#165)) ### Other - no more duplicate candidate generation ([#181](#181)) - *(deps)* lock file maintenance ([#180](#180)) - *(deps)* update swatinem/rust-cache digest to e18b497 ([#179](#179)) - *(deps)* lock file maintenance ([#178](#178)) - *(deps)* lock file maintenance ([#176](#176)) - Remove codspeed walltime benchmark ([#177](#177)) - Add more micro benchmarks ([#171](#171)) - *(deps)* update marcoieni/release-plz-action digest to 1528104 ([#170](#170)) - *(deps)* update codspeedhq/action digest to 281164b ([#169](#169)) - *(deps)* update actions/upload-artifact action to v7 ([#167](#167)) - *(deps)* lock file maintenance ([#168](#168)) - *(deps)* update actions/upload-artifact action to v6 ([#160](#160)) - *(deps)* lock file maintenance ([#164](#164)) - *(deps)* update swatinem/rust-cache digest to 779680d ([#157](#157)) - *(deps)* update actions/checkout digest to de0fac2 ([#158](#158)) - *(deps)* update codspeedhq/action digest to 2ac5728 ([#162](#162)) - *(deps)* update marcoieni/release-plz-action digest to f708778 ([#166](#166)) - *(deps)* update marcoieni/release-plz-action digest to 52440b5 ([#156](#156)) - *(deps)* lock file maintenance ([#161](#161)) - *(deps)* lock file maintenance ([#159](#159)) - *(deps)* update actions/checkout action to v6 ([#154](#154)) - *(deps)* lock file maintenance ([#155](#155)) - *(deps)* update codspeedhq/action digest to 346a2d8 ([#152](#152)) - *(deps)* update actions/checkout digest to 93cb6ef ([#151](#151)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR addresses two buffer boundary bugs within the
compress_intoanddecompress_intoAPIs.decompress_into- Utilized a fallback loop (while out_end.offset_from(out_ptr) > 8) to decode trailing bytes. If a caller provided exactly the uncompressed string's length as the target capacity, the loop would terminate prematurely if there were< 8bytes of remaining capacity. This resulted in anassertion 'left == right' failed: decompression should exhaust input before outputpanic.compress_into- Iterated over the input relying onwhile out_ptr < out_end. However,compress_wordcan emit anESCAPE_CODEfollowed by a literal byte, which advancesout_ptrby2. Ifout_ptrwas atout_end - 1, the loop condition evaluated totrue, but the second byte write would overwrite unowned memory past the allocation boundary.Added a test for exactly-sized buffers in
tests/exact_capacity.rs.