summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-05 17:50:28 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-05 17:50:28 +0100
commita79925a0a8f00577782090859eb0ef69e220d4aa (patch)
tree2b6b2bb3a90f09a256d5b6dbdfefac238c015d65
parent752fc692ace51459cb407ec117c147b3bbebc071 (diff)
downloadvim-git-a79925a0a8f00577782090859eb0ef69e220d4aa.tar.gz
patch 8.2.2302: Vim9: using an option value may use uninitialized memoryv8.2.2302
Problem: Vim9: using an option value may use uninitialized memory. Solution: Clear v_lock. (closes #7620)
-rw-r--r--src/testdir/test_vim9_expr.vim9
-rw-r--r--src/typval.c1
-rw-r--r--src/version.c2
3 files changed, 12 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 494165065..d835f04a9 100644
--- 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()
diff --git a/src/typval.c b/src/typval.c
index 421e62a37..d16f0e6df 100644
--- 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;
diff --git a/src/version.c b/src/version.c
index c01221cc6..e7c3ee0a0 100644
--- 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,