diff options
author | Christian Brabandt <cb@256bit.org> | 2024-04-11 22:54:44 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-11 22:54:44 +0200 |
commit | bba79808cb115d4f54063e8aa40628a927eab44e (patch) | |
tree | bb366b70f555f943ebd425eae06da59d96198386 /src/textformat.c | |
parent | 7b0c4b64e3012c24b928a4452963d53cae147a51 (diff) |
patch 9.1.0309: crash when 'textwidth' > MAX_INTv9.1.0309
Problem: crash when 'textwidth' > MAX_INT (after vv9.1.0055)
(Zoltan Balogh)
Solution: limit textwidth to MAX_INT
fixes: #14482
closes: #14489
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/textformat.c')
-rw-r--r-- | src/textformat.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/textformat.c b/src/textformat.c index 14acc53cd0..41ec2cfe4b 100644 --- a/src/textformat.c +++ b/src/textformat.c @@ -56,6 +56,7 @@ internal_format( colnr_T leader_len; int no_leader = FALSE; int do_comments = (flags & INSCHAR_DO_COM); + int safe_tw = trim_to_int(8 * (vimlong_T)textwidth); #ifdef FEAT_LINEBREAK int has_lbr = curwin->w_p_lbr; @@ -95,7 +96,7 @@ internal_format( // Cursor is currently at the end of line. No need to format // if line length is less than textwidth (8 * textwidth for // utf safety) - if (curwin->w_cursor.col < 8 * textwidth) + if (curwin->w_cursor.col < safe_tw) { virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor()); @@ -156,8 +157,7 @@ internal_format( // line to textwidth border every time for each line break. // // Ceil to 8 * textwidth to optimize. - curwin->w_cursor.col = startcol < 8 * textwidth ? startcol : - 8 * textwidth; + curwin->w_cursor.col = startcol < safe_tw ? startcol : safe_tw; foundcol = 0; skip_pos = 0; |