Skip to content

Commit

Permalink
patch 9.0.0104: going beyond allocated memory when evaluating string …
Browse files Browse the repository at this point in the history
…constant

Problem:    Going beyond allocated memory when evaluating string constant.
Solution:   Properly skip over <Key> form.
  • Loading branch information
brammool committed Jul 29, 2022
1 parent efffa53 commit 1e56bda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/testdir/test_eval_stuff.vim
Expand Up @@ -617,4 +617,9 @@ func Test_modified_char_no_escape_special()
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ö%
endfunc

" vim: shiftwidth=2 sts=2 expandtab
12 changes: 12 additions & 0 deletions src/typval.c
Expand Up @@ -2090,7 +2090,19 @@ eval_string(char_u **arg, typval_T *rettv, int evaluate, int interpolate)
// 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 == '}'))
{
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -735,6 +735,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
104,
/**/
103,
/**/
Expand Down

0 comments on commit 1e56bda

Please sign in to comment.