From: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Thu, 15 Jan 2026 20:14:08 +0000 (+0000) Subject: patch 9.1.2086: Memory leak when skipping invalid literal dict X-Git-Tag: v9.1.2086^0 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b10a3e1a20c444ffea34be820e8ceba4b2503287;p=thirdparty%2Fvim.git patch 9.1.2086: Memory leak when skipping invalid literal dict Problem: memory leak when not evaluating (just parsing) invalid literal dict. Solution: Always clear the key's typval (Sean Dewar) Though "check_typval_is_value(&tv) == FAIL && !evaluate" is maybe never true, also always clear tvs if check_typval_is_value fails; at worst this would be a no-op as their initial types are VAR_UNKNOWN. closes: #19178 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt --- diff --git a/src/dict.c b/src/dict.c index f539250af9..0eb5a481aa 100644 --- a/src/dict.c +++ b/src/dict.c @@ -1038,17 +1038,13 @@ eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal) *arg = skipwhite_and_linebreak(*arg + 1, evalarg); if (eval1(arg, &tv, evalarg) == FAIL) // recursive! { - if (evaluate) - clear_tv(&tvkey); + clear_tv(&tvkey); goto failret; } if (check_typval_is_value(&tv) == FAIL) { - if (evaluate) - { - clear_tv(&tvkey); - clear_tv(&tv); - } + clear_tv(&tvkey); + clear_tv(&tv); goto failret; } if (evaluate) diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim index 4e22f63acd..316e3614fc 100644 --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -575,6 +575,8 @@ func Test_dict_literal_keys() " why *{} cannot be used for a literal dictionary let blue = 'blue' call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue'))) + + call assert_fails('eval 1 || #{a:', 'E15:') " used to leak endfunc " Nasty: deepcopy() dict that refers to itself (fails when noref used) diff --git a/src/version.c b/src/version.c index 3e3bae84b9..b4e8e8a6dd 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 2086, /**/ 2085, /**/