patch 9.1.1041: Vim9: out-of-bound access when echoing an enum Commit: https://github.com/vim/vim/commit/cb848b687f9b6ec7b1c3d903d3ff84fc1f52d8e3 Author: Yegappan Lakshmanan <yegap...@yahoo.com> Date: Mon Jan 20 21:38:09 2025 +0100
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 <yegap...@yahoo.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/src/testdir/test_vim9_enum.vim b/src/testdir/test_vim9_enum.vim index 74eb46880..de26259d4 100644 --- a/src/testdir/test_vim9_enum.vim +++ b/src/testdir/test_vim9_enum.vim @@ -1586,4 +1586,19 @@ def Test_lambda_block_in_enum() v9.CheckScriptSuccess(lines) enddef +" Echo an enum +def Test_enum_echo() + var lines =<< trim END + vim9script + enum Demo + one('tahi'), + two('rua'), + three('toru') + var alias: string + endenum + assert_equal('enum Demo.one {name: one, ordinal: 0, alias: tahi}', execute('echo Demo.one')->split(" ")[0]) + END + v9.CheckScriptSuccess(lines) +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index 8e5315957..5b3683ddd 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1041, /**/ 1040, /**/ diff --git a/src/vim9class.c b/src/vim9class.c index c3ccf0250..e847bf086 100644 --- a/src/vim9class.c +++ b/src/vim9class.c @@ -4054,6 +4054,7 @@ object2string( vim_free(ga.ga_data); return NULL; } + ga_append(&ga, NUL); return (char_u *)ga.ga_data; } diff --git a/src/vim9expr.c b/src/vim9expr.c index 7b8c96adb..b76544869 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -406,7 +406,7 @@ compile_class_object_index(cctx_T *cctx, char_u **arg, type_T *type) } } - if (is_super && IS_ABSTRACT_METHOD(ufunc)) + if (is_super && ufunc != NULL && IS_ABSTRACT_METHOD(ufunc)) { // Trying to invoke an abstract method in a super class is not // allowed. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1tZydr-007rKc-3B%40256bit.org.