Skip to content

Fix tab expansion for tab sizes greater than eight - #1457

Merged
koutcher merged 1 commit into
jonas:masterfrom
hezhizhen:codex/fix-tab-expansion
Oct 13, 2026
Merged

koutcher merged 1 commit into
jonas:masterfrom
hezhizhen:codex/fix-tab-expansion

Conversation

@hezhizhen

Copy link
Copy Markdown
Contributor

string_expand() expands tabs by copying from an eight-space string. With tab-size = 9, this can copy the terminating NUL and truncate displayed text; larger tab sizes read past the literal (reproduced with AddressSanitizer at 16 and 32).

Fill the already bounded destination range with memset() and add a regression test for tab sizes 8, 9, 16 and 32. The test checks exact spacing for leading, consecutive and aligned tabs.

Validation:

  • The regression fails on the original implementation and passes after the fix: 8 assertions in the normal build.
  • AddressSanitizer test suite: 157 tests, 590 assertions passed.
  • git diff --check passed.

@koutcher
koutcher merged commit 7df68c1 into jonas:master Oct 13, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants