Commit: patch 9.1.2086: Memory leak when skipping invalid literal dict

1 view
Skip to first unread message

Christian Brabandt

unread,
Jan 15, 2026, 3:31:15 PM (15 hours ago) Jan 15
to vim...@googlegroups.com
patch 9.1.2086: Memory leak when skipping invalid literal dict

Commit: https://github.com/vim/vim/commit/b10a3e1a20c444ffea34be820e8ceba4b2503287
Author: Sean Dewar <6256228+...@users.noreply.github.com>
Date: Thu Jan 15 20:14:08 2026 +0000

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+...@users.noreply.github.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/dict.c b/src/dict.c
index f539250af..0eb5a481a 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 4e22f63ac..316e3614f 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 3e3bae84b..b4e8e8a6d 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,
/**/
Reply all
Reply to author
Forward
0 new messages