Skip to content

Commit cb848b6

Browse files
yegappanchrisbra
authored andcommitted
patch 9.1.1041: Vim9: out-of-bound access when echoing an enum
Problem: Vim9: out-of-bound access when echoing an enum Solution: Add NUL to growarray, check that ufunc is non-null before accessing it to make Coverity happy (Yegappan Lakshmanan) closes: #16488 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent d79ea47 commit cb848b6

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/testdir/test_vim9_enum.vim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,4 +1586,19 @@ def Test_lambda_block_in_enum()
15861586
v9.CheckScriptSuccess(lines)
15871587
enddef
15881588

1589+
" Echo an enum
1590+
def Test_enum_echo()
1591+
var lines =<< trim END
1592+
vim9script
1593+
enum Demo
1594+
one('tahi'),
1595+
two('rua'),
1596+
three('toru')
1597+
var alias: string
1598+
endenum
1599+
assert_equal('enum Demo.one {name: one, ordinal: 0, alias: tahi}', execute('echo Demo.one')->split("\n")[0])
1600+
END
1601+
v9.CheckScriptSuccess(lines)
1602+
enddef
1603+
15891604
" 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+
1041,
707709
/**/
708710
1040,
709711
/**/

src/vim9class.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4054,6 +4054,7 @@ object2string(
40544054
vim_free(ga.ga_data);
40554055
return NULL;
40564056
}
4057+
ga_append(&ga, NUL);
40574058
return (char_u *)ga.ga_data;
40584059
}
40594060

src/vim9expr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type)
406406
}
407407
}
408408

409-
if (is_super && IS_ABSTRACT_METHOD(ufunc))
409+
if (is_super && ufunc != NULL && IS_ABSTRACT_METHOD(ufunc))
410410
{
411411
// Trying to invoke an abstract method in a super class is not
412412
// allowed.

0 commit comments

Comments
 (0)