Patch 9.0.0104

2 views
Skip to first unread message

Bram Moolenaar

unread,
Jul 29, 2022, 10:29:20 AM7/29/22
to vim...@googlegroups.com

Patch 9.0.0104
Problem: Going beyond allocated memory when evaluating string constant.
Solution: Properly skip over <Key> form.
Files: src/typval.c, src/testdir/test_eval_stuff.vim


*** ../vim-9.0.0103/src/typval.c 2022-05-10 18:11:14.000000000 +0100
--- src/typval.c 2022-07-29 15:25:51.351514707 +0100
***************
*** 2090,2096 ****
--- 2090,2108 ----
// 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 == '}'))
{
*** ../vim-9.0.0103/src/testdir/test_eval_stuff.vim 2022-05-02 22:44:31.000000000 +0100
--- src/testdir/test_eval_stuff.vim 2022-07-29 15:23:13.367617961 +0100
***************
*** 617,620 ****
--- 617,625 ----
nunmap <M-…>
endfunc

+ func Test_eval_string_in_special_key()
+ " this was using the '{' inside <> as the start of an interpolated string
+ silent! echo 0{1-$"\<S--{> n|nö%
Reply all
Reply to author
Forward
0 new messages