Skip to content

Commit a3571eb

Browse files
committed
patch 8.0.1346: crash when passing 50 char string to balloon_split()
Problem: Crash when passing 50 char string to balloon_split(). Solution: Fix off-by-one error.
1 parent c41838a commit a3571eb

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/popupmnu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ split_message(char_u *mesg, pumitem_T **array)
836836
item->bytelen = p - item->start;
837837
if (item->cells > max_cells)
838838
max_cells = item->cells;
839-
long_item_count += item->cells / BALLOON_MIN_WIDTH;
839+
long_item_count += (item->cells - 1) / BALLOON_MIN_WIDTH;
840840
}
841841

842842
height = 2 + ga.ga_len;

src/testdir/test_popup.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,10 @@ func Test_balloon_split()
707707
if !exists('*balloon_split')
708708
return
709709
endif
710+
call assert_equal([
711+
\ 'tempname: 0x555555e380a0 "/home/mool/.viminfz.tmp"',
712+
\ ], balloon_split(
713+
\ 'tempname: 0x555555e380a0 "/home/mool/.viminfz.tmp"'))
710714
call assert_equal([
711715
\ 'one two three four one two three four one two thre',
712716
\ 'e four',

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,8 @@ static char *(features[]) =
771771

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1346,
774776
/**/
775777
1345,
776778
/**/

0 commit comments

Comments
 (0)