From: Bram Moolenaar Date: Fri, 29 Jul 2022 14:28:27 +0000 (+0100) Subject: patch 9.0.0104: going beyond allocated memory when evaluating string constant X-Git-Tag: v9.0.0104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e56bda9048a9625bce6e660938c834c5c15b07d;p=thirdparty%2Fvim.git 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 form. --- diff --git a/src/testdir/test_eval_stuff.vim b/src/testdir/test_eval_stuff.vim index 3c168f2f59..c63082e8e8 100644 --- a/src/testdir/test_eval_stuff.vim +++ b/src/testdir/test_eval_stuff.vim @@ -617,4 +617,9 @@ func Test_modified_char_no_escape_special() nunmap endfunc +func Test_eval_string_in_special_key() + " this was using the '{' inside <> as the start of an interpolated string + silent! echo 0{1-$"\n|nö% +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/typval.c b/src/typval.c index a266330622..8b69adfcc8 100644 --- a/src/typval.c +++ b/src/typval.c @@ -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 == '}')) { diff --git a/src/version.c b/src/version.c index 9f6b19499e..8c55a62e9d 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 104, /**/ 103, /**/