patch 9.1.2086: Memory leak when skipping invalid literal dict

Commit: 
https://github.com/vim/vim/commit/b10a3e1a20c444ffea34be820e8ceba4b2503287
Author: Sean Dewar <[email protected]>
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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vgTyl-00Ei5B-Sd%40256bit.org.

Raspunde prin e-mail lui