Commit 8eb6542
authored
zstd: Fix corrupted output in "best" (#876)
* zstd: Fix corrupted output in "best"
Regression from #784 and followup #793
Fixes #875
A 0 offset backreference was possible when "improve" was successful twice in a row in the "skipBeginning" part, only finding 2 (previously unmatches) length 4 matches, but where start offset decreased by 2 in both cases.
This would result in output where the end offset would equal to the next 's', thereby doing a self-reference.
Add a general check in "improve" and just reject these. Will also guard against similar issues in the future.
This also hints at some potentially suboptimal hash indexing - but I will take that improvement separately.
Fuzz test set updated.1 parent 68eabfa commit 8eb6542
2 files changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
| 201 | + | |
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | | - | |
205 | | - | |
| 205 | + | |
| 206 | + | |
206 | 207 | | |
207 | 208 | | |
208 | 209 | | |
| |||
343 | 344 | | |
344 | 345 | | |
345 | 346 | | |
346 | | - | |
347 | | - | |
| 347 | + | |
| 348 | + | |
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
| |||
Binary file not shown.
0 commit comments