Skip to content

Commit 2050dcc

Browse files
yegappanchrisbra
authored andcommitted
patch 9.1.0992: Vim9: double-free after v9.1.0988
Problem: Vim9: double-free after v9.1.0988 (h-east) Solution: clear typval pointer, before setting the type (Yegappan Lakshmanan) Otherwise the contents are still referring to some other value. fixes: #16386 closes: #16388 Signed-off-by: Yegappan Lakshmanan <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 6655bef commit 2050dcc

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/testdir/test_vim9_class.vim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11839,4 +11839,31 @@ def Test_uninitialized_object_var()
1183911839
v9.CheckSourceFailure(lines, "E1430: Uninitialized object variable 'x' referenced")
1184011840
enddef
1184111841

11842+
" Test for initializing member variables of compound type in the constructor
11843+
def Test_constructor_init_compound_member_var()
11844+
var lines =<< trim END
11845+
vim9script
11846+
11847+
class Foo
11848+
var v1: string = "aaa"
11849+
var v2: list<number> = [1, 2]
11850+
var v3: dict<string> = {a: 'a', b: 'b'}
11851+
endclass
11852+
11853+
class Bar
11854+
var v4: string = "bbb"
11855+
var v5: Foo = Foo.new()
11856+
var v6: list<number> = [1, 2]
11857+
endclass
11858+
11859+
var b: Bar = Bar.new()
11860+
assert_equal("aaa", b.v5.v1)
11861+
assert_equal([1, 2], b.v5.v2)
11862+
assert_equal({a: 'a', b: 'b'}, b.v5.v3)
11863+
assert_equal("bbb", b.v4)
11864+
assert_equal([1, 2], b.v6)
11865+
END
11866+
v9.CheckSourceSuccess(lines)
11867+
enddef
11868+
1184211869
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/version.c

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

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
992,
707709
/**/
708710
991,
709711
/**/

src/vim9execute.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4855,6 +4855,7 @@ exec_instructions(ectx_T *ectx)
48554855
+ iptr->isn_arg.jumparg.jump_arg_off
48564856
+ STACK_FRAME_SIZE;
48574857
type_T *t = ufunc->uf_arg_types[argidx];
4858+
CLEAR_POINTER(tv);
48584859
tv->v_type = t->tt_type;
48594860
}
48604861

0 commit comments

Comments
 (0)