diffutils: fix panic on non-UTF-8 argument ending in --width=N#250
diffutils: fix panic on non-UTF-8 argument ending in --width=N#250SAY-5 wants to merge 1 commit into
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Merging this PR will degrade performance by 3.03%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | cmd_cmp_gnu_equal[1000] |
12.2 µs | 13.1 µs | -6.35% |
| ❌ | Simulation | cmd_cmp_release_equal[25000] |
13 µs | 13.7 µs | -5.76% |
| ❌ | Simulation | cmd_cmp_release_equal[100] |
13.2 µs | 13.8 µs | -4.16% |
| ❌ | Simulation | cmd_cmp_release_equal[10000] |
13 µs | 13.5 µs | -3.74% |
| ⚡ | Simulation | cmd_diff_release_equal[1000] |
13.5 µs | 12.9 µs | +5.28% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing SAY-5:fix-width-non-utf8-panic (8fdc882) with main (dc9ca17)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #250 +/- ##
===========================
===========================
☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
diffpanicked with exit 101 on a non-UTF-8 argument whose lossy form ends in--width=N, e.g.diff $'\xff--width=5' A B. The--widthregex was missing the leading^anchor that--tabsizealready has, so the lossy (U+FFFD) form matched and the followinginto_string().unwrap()then failed on the real bytes.Anchoring the regex (
^--width=...$, matchingtabsize_re) makes such an argument fall through to the operand path instead of being parsed as a width option, so it no longer panics. As a side effectdiff xyz--width=5is now also treated as a filename rather than silently accepting a width.Added a
widthtest and a#[cfg(unix)]regression test for the non-UTF-8 case.Fixes #247.