Skip to content

fix: word_wrap crash from unsigned integer underflow - #82

Merged
meszmate merged 1 commit into
mainfrom
fix/word-wrap-crash
Mar 31, 2026
Merged

meszmate merged 1 commit into
mainfrom
fix/word-wrap-crash

Conversation

@meszmate

@meszmate meszmate commented Mar 31, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes crash in applyWordWrap when running text_overflow example
  • Root cause: result.items.len - visible_width underflows when visible_width > result.items.len (unsigned subtraction)
  • Rewrote word_wrap to use a word-at-a-time approach that collects words, measures them, and wraps before emitting — no in-place buffer index manipulation

The previous word_wrap implementation could underflow on
result.items.len - visible_width when visible_width exceeded the
result length. Rewritten to use a word-at-a-time approach that
avoids in-place buffer manipulation entirely.
@meszmate
meszmate merged commit e5eeb8b into main Mar 31, 2026
9 checks passed
@meszmate
meszmate deleted the fix/word-wrap-crash branch April 24, 2026 13:39
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.

1 participant