diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-07-29 15:28:27 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-07-29 15:28:27 +0100 |
commit | 1e56bda9048a9625bce6e660938c834c5c15b07d (patch) | |
tree | 14c291c59ee5009b6cef310c9be6f72284261f66 /src/typval.c | |
parent | efffa5360ebb2b6919c5eb1998c5df4c8849a407 (diff) |
patch 9.0.0104: going beyond allocated memory when evaluating string constantv9.0.0104
Problem: Going beyond allocated memory when evaluating string constant.
Solution: Properly skip over <Key> form.
Diffstat (limited to 'src/typval.c')
-rw-r--r-- | src/typval.c | 12 |
1 files changed, 12 insertions, 0 deletions
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 == '}')) { |