Skip to content

Commit a79925a

Browse files
committed
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 #7620)
1 parent 752fc69 commit a79925a

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/testdir/test_vim9_expr.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,6 +2426,10 @@ def Test_expr_member_vim9script()
24262426
CheckScriptSuccess(lines)
24272427
enddef
24282428

2429+
def SetSomeVar()
2430+
b:someVar = &fdm
2431+
enddef
2432+
24292433
def Test_expr7_option()
24302434
# option
24312435
set ts=11
@@ -2443,6 +2447,11 @@ def Test_expr7_option()
24432447
var bval: bool = &tgc
24442448
var nval: number = &ts
24452449
var sval: string = &path
2450+
2451+
# check v_lock is cleared (requires using valgrind, doesn't always show)
2452+
SetSomeVar()
2453+
b:someVar = 0
2454+
unlet b:someVar
24462455
enddef
24472456

24482457
def Test_expr7_environment()

src/typval.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,7 @@ eval_option(
11171117
}
11181118
else if (rettv != NULL)
11191119
{
1120+
rettv->v_lock = 0;
11201121
if (opt_type == gov_hidden_string)
11211122
{
11221123
rettv->v_type = VAR_STRING;

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2302,
753755
/**/
754756
2301,
755757
/**/

0 commit comments

Comments
 (0)