Mercurial > vim
changeset 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 | db3afe53702b |
children | 575f2686d4a8 |
files | src/testdir/test_eval_stuff.vim src/typval.c src/version.c |
diffstat | 3 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
index 3c168f2f59b58599dd68c262a83e472838c08c43..c63082e8e8b6dcc823d2fee3f3054ee363e8f11e GIT binary patch literal 23684 zc%02#>vHS3k<Q=v0cQVVnCzjvYs(@fU(0f>FY=6QCz;fo)TybmT`H1-B<4`0mZW^i znW@Ut>?7<8?3?6C(zp;85}@dFGBxqckw~Ds@pYroXn-Od^k-a@1)66$dJ6J5+Y|^t z1qmvbak?n_J3B?T$s>%OV*EValyTC3idQ>3^GzC+ah9UuY@TJkT@-{_UhW`N=CAOH zP>#z@o}&9lG#;Y?6h%Q9E!8RyZg4sy4DeM6WTGjmDP@^5^67J2E~hxpv%I%U#U%*} ziUQ~56#vgANP6C01!lJrs0vH7N?cK9Ii41Af>YpK6$>hm-G40<D3^KmOhH!2Ias)e zmKh*H?sJ}{3luDZICYJfG>Sd+KFTppzl&4cdzZjxVTQW;IE(Y?TIxv)dhU<(`vCY# zJOgp=+O3<S%s03f7eIz1Q1i9Uw7aYHk%Ru6zd|>oGDEB2BS!coE=p2R@yED8vkVuh zTOw+E%Gbms!E{6n7DWe><KgMqfn?%3<aiCf)N`4Pe!stmoVBxy<^gokjJj%&HnF}^ z(V~+a(wG2WY}RY&`2w5|oSUjrRHl2*;}Xw7cJKZXApS@$8-^u~7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Tn?39zSk?GLzF|$%VvLp%8MB z6pW~3Bt@fthHTVFb?H#_&y;U!;B74c(I%Chr`#^oTh@ujgF`T0Ludl0D5{gb9C|(| zdJYPdL*ykPhP>vT%~4SX(MO|GI`{=67p63-L5|lrfJwgxNWH<p=VwWJN2h0KB61{{ zUoym-e!^#{*HazVLH|8{|EJ0I-Q{=W(7kd=&Krf`6q6Uomq8vxB}_~7%)SsKTtvYd z&-T#sGKOS~9v)hNj9IpU8Ec<b6GiBr-W=wukNCCd?UJ|DK}{l@pMy+at|qz$DLN<l z+yz<%Yr?w+;>a{w9b&tpr$aq2gOW^Y1QN(&Qi?tG{9ulnypx|#(`?GHPKz~;=m`U0 z(3G683hkitKkWbgZ~uFN&aYRq3*K`X$e7{;!gT@N@}FbmonQZOQFVh*#(Ch(#MsRv zBltNW3Xwp)D~Gz?R&`diwV4-NI}n%Z(g-27$}N2K*tElqE@iSQh<X56g<6Dl!uhR# zAvqh6ptco{Z^kpjiGV~J+^{A=nmTkeHie8~HXfn@Zd4ssMUGQoT|EV~^%1ry=#kIh zfbJ(39KDEV7@c2KUI`;EFS$F?gK*bb5|rTcO!$sGDVydWgHPW6@4+1J_xC?t{9F1{ n`v3p;@4r#U)Kk1VgUl_Sm(TI6T#kJZRKO<~8GIWunw@_D6ekFg
--- 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 == '}')) {