Skip to content

Improve handling of overlong single lines#19332

Open
chrisbra wants to merge 2 commits intovim:masterfrom
chrisbra:gh-18593-overlong-lines
Open

Improve handling of overlong single lines#19332
chrisbra wants to merge 2 commits intovim:masterfrom
chrisbra:gh-18593-overlong-lines

Conversation

@chrisbra
Copy link
Member

@chrisbra chrisbra commented Feb 4, 2026

Problem: reading files with very long lines crashes Vim
Solution: break long lines, use (long) instead of (int) to handle
the line length so that it doesn't overflow

fixes: #17935
related: #18953

Note: I used Claude to help with this.

Problem:  ml_append_int() crashes when appending lines near MAXCOL
          length due to signed integer overflow in space_needed
          calculation.
Solution: Change 'space_needed' from int to long to handle the
          'len + INDEX_SIZE' computation without overflow. Update
          db_free comparison casts from (int) to (long) to match.

Note: supported by AI claude

related: vim#17935
related: vim#18953

Signed-off-by: Christian Brabandt <cb@256bit.org>
…rflow

Problem:  Reading files with lines approaching MAXCOL length crashes
          with segfault due to colnr_T overflow.
Solution: The split check 'linerest >= MAXCOL' fired too late because
          linerest could grow by up to 'size' bytes before the next
          check. Change threshold to 'linerest >= MAXCOL - size' to
          ensure the line passed to ml_append() stays within colnr_T
          range.

fixes:   vim#17935
closes:  vim#18953

Note: supported by AI claude

Signed-off-by: Christian Brabandt <cb@256bit.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vi crash occasionally when opening large file

1 participant