changeset 12940:5045d3076db0 v8.0.1346

patch 8.0.1346: crash when passing 50 char string to balloon_split() commit https://github.com/vim/vim/commit/a3571ebef5a2969d16e3e202ec4bca8858aca6ba Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 26 16:53:16 2017 +0100 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.
author Christian Brabandt <cb@256bit.org>
date Sun, 26 Nov 2017 17:00:07 +0100
parents f5b8129cef2f
children c9bec4e3805f
files src/popupmnu.c src/testdir/test_popup.vim src/version.c
diffstat 3 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -836,7 +836,7 @@ split_message(char_u *mesg, pumitem_T **
 	item->bytelen = p - item->start;
 	if (item->cells > max_cells)
 	    max_cells = item->cells;
-	long_item_count += item->cells / BALLOON_MIN_WIDTH;
+	long_item_count += (item->cells - 1) / BALLOON_MIN_WIDTH;
     }
 
     height = 2 + ga.ga_len;
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -708,6 +708,10 @@ func Test_balloon_split()
     return
   endif
   call assert_equal([
+        \ 'tempname: 0x555555e380a0 "/home/mool/.viminfz.tmp"',
+        \ ], balloon_split(
+        \ 'tempname: 0x555555e380a0 "/home/mool/.viminfz.tmp"'))
+  call assert_equal([
         \ 'one two three four one two three four one two thre',
         \ 'e four',
         \ ], balloon_split(
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1346,
+/**/
     1345,
 /**/
     1344,