changeset 23519:cb66613dd9d5 v8.2.2302

patch 8.2.2302: Vim9: using an option value may use uninitialized memory Commit: https://github.com/vim/vim/commit/a79925a0a8f00577782090859eb0ef69e220d4aa Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jan 5 17:50:28 2021 +0100 patch 8.2.2302: Vim9: using an option value may use uninitialized memory Problem: Vim9: using an option value may use uninitialized memory. Solution: Clear v_lock. (closes https://github.com/vim/vim/issues/7620)
author Bram Moolenaar <Bram@vim.org>
date Tue, 05 Jan 2021 18:00:04 +0100
parents e7e55755e933
children 9c0c0d1a38f6
files src/testdir/test_vim9_expr.vim src/typval.c src/version.c
diffstat 3 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -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()
--- a/src/typval.c
+++ b/src/typval.c
@@ -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;
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2302,
+/**/
     2301,
 /**/
     2300,