changeset 29332:a538982f74ea v9.0.0009

patch 9.0.0009: going past the end of a menu item with only modifier Commit: https://github.com/vim/vim/commit/083692d598139228e101b8c521aaef7bcf256e9a Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jun 29 21:16:58 2022 +0100 patch 9.0.0009: going past the end of a menu item with only modifier Problem: Going past the end of a menu item with only modifier. Solution: Check for NUL.
author Bram Moolenaar <Bram@vim.org>
date Wed, 29 Jun 2022 22:30:03 +0200
parents d78c62e61b42
children 38a15f3738a2
files src/message.c src/testdir/test_menu.vim src/version.c
diffstat 3 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/message.c
+++ b/src/message.c
@@ -1820,8 +1820,8 @@ str2special(
 	    *sp = str + 1;
     }
     else
-	// single-byte character or illegal byte
-	*sp = str + 1;
+	// single-byte character, NUL or illegal byte
+	*sp = str + (*str == NUL ? 0 : 1);
 
     // Make special keys and C0 control characters in <> form, also <M-Space>.
     // Use <Space> only for lhs of a mapping.
--- a/src/testdir/test_menu.vim
+++ b/src/testdir/test_menu.vim
@@ -528,4 +528,17 @@ func Test_tmenu()
   tunmenu Test
 endfunc
 
+func Test_only_modifier()
+  exe "tmenu a.b \x80\xfc0"
+  let exp =<< trim [TEXT]
+  --- Menus ---
+  500 a
+    500 b
+        t  - <T-2-^@>
+  [TEXT]
+  call assert_equal(exp, split(execute('tmenu'), "\n"))
+
+  tunmenu a.b
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    9,
+/**/
     8,
 /**/
     7,