diff src/typval.c @ 29525:5063dfe96a59 v9.0.0104

patch 9.0.0104: going beyond allocated memory when evaluating string constant Commit: https://github.com/vim/vim/commit/1e56bda9048a9625bce6e660938c834c5c15b07d Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jul 29 15:28:27 2022 +0100 patch 9.0.0104: going beyond allocated memory when evaluating string constant Problem: Going beyond allocated memory when evaluating string constant. Solution: Properly skip over <Key> form.
author Bram Moolenaar <Bram@vim.org>
date Fri, 29 Jul 2022 16:30:04 +0200
parents 006d525419fa
children 86eb4aba16c3
line wrap: on
line diff
--- a/src/typval.c
+++ b/src/typval.c
@@ -2090,7 +2090,19 @@ eval_string(char_u **arg, typval_T *rett
 	    // to 9 characters (6 for the char and 3 for a modifier):
 	    // reserve space for 5 extra.
 	    if (*p == '<')
+	    {
+		int		modifiers = 0;
+		int		flags = FSK_KEYCODE | FSK_IN_STRING;
+
 		extra += 5;
+
+		// Skip to the '>' to avoid using '{' inside for string
+		// interpolation.
+		if (p[1] != '*')
+		    flags |= FSK_SIMPLIFY;
+		if (find_special_key(&p, &modifiers, flags, NULL) != 0)
+		    --p;  // leave "p" on the ">"
+	    }
 	}
 	else if (interpolate && (*p == '{' || *p == '}'))
 	{