# HG changeset patch # User Bram Moolenaar # Date 1609866004 -3600 # Node ID cb66613dd9d55411c368150486a7ba1cc00c16ca # Parent e7e55755e9337727dcab17992db3844be005bd55 patch 8.2.2302: Vim9: using an option value may use uninitialized memory Commit: https://github.com/vim/vim/commit/a79925a0a8f00577782090859eb0ef69e220d4aa Author: Bram Moolenaar 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) diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- 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 --- 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 --- 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,