]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2302: Vim9: using an option value may use uninitialized memory v8.2.2302
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Jan 2021 16:50:28 +0000 (17:50 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Jan 2021 16:50:28 +0000 (17:50 +0100)
Problem:    Vim9: using an option value may use uninitialized memory.
Solution:   Clear v_lock. (closes #7620)

src/testdir/test_vim9_expr.vim
src/typval.c
src/version.c

index 4941650650220e4f20ce48d880b8e3a5103c094d..d835f04a96b86afe2fd841c9b8618fa9bea9a56f 100644 (file)
@@ -2426,6 +2426,10 @@ def Test_expr_member_vim9script()
   CheckScriptSuccess(lines)
 enddef
 
+def SetSomeVar()
+  b:someVar = &fdm
+enddef
+
 def Test_expr7_option()
   # option
   set ts=11
@@ -2443,6 +2447,11 @@ def Test_expr7_option()
   var bval: bool = &tgc
   var nval: number = &ts
   var sval: string = &path
+
+  # check v_lock is cleared (requires using valgrind, doesn't always show)
+  SetSomeVar()
+  b:someVar = 0
+  unlet b:someVar
 enddef
 
 def Test_expr7_environment()
index 421e62a37c69410326e7c11cfbc0c0b1839d3c8f..d16f0e6df85de8934c0b07f7318791ca6dd63c04 100644 (file)
@@ -1117,6 +1117,7 @@ eval_option(
     }
     else if (rettv != NULL)
     {
+       rettv->v_lock = 0;
        if (opt_type == gov_hidden_string)
        {
            rettv->v_type = VAR_STRING;
index c01221cc6c567bcd1f0215e6afdaff87b347be55..e7c3ee0a0d044963fb807d6fefdb350ef8b55074 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2302,
 /**/
     2301,
 /**/