diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-05 12:36:47 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-05-05 19:43:13 +0800 |
commit | 5fb6b3431a52932dcc50bcc930f8b2c9b71a1bb0 (patch) | |
tree | f6b7010d0d237c7f684f80fa56ae4a17872f9965 /src/nvim/testing.c | |
parent | 17c8e39f8803daa6f0e6106ce1c087240cef4771 (diff) | |
download | rneovim-5fb6b3431a52932dcc50bcc930f8b2c9b71a1bb0.tar.gz rneovim-5fb6b3431a52932dcc50bcc930f8b2c9b71a1bb0.tar.bz2 rneovim-5fb6b3431a52932dcc50bcc930f8b2c9b71a1bb0.zip |
vim-patch:9.0.0404: crash when passing invalid arguments to assert_fails()
Problem: Crash when passing invalid arguments to assert_fails().
Solution: Check for NULL string.
https://github.com/vim/vim/commit/1540d334a04d874c2aa9d26b82dbbcd4bc5a78de
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/testing.c')
-rw-r--r-- | src/nvim/testing.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/testing.c b/src/nvim/testing.c index 25149f1b38..92747822b4 100644 --- a/src/nvim/testing.c +++ b/src/nvim/testing.c @@ -531,6 +531,11 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) no_wait_return++; do_cmdline_cmd(cmd); + + // reset here for any errors reported below + trylevel = save_trylevel; + suppress_errthrow = false; + if (called_emsg == called_emsg_before) { prepare_assert_error(&ga); ga_concat(&ga, "command did not fail: "); @@ -557,6 +562,9 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } const typval_T *tv = TV_LIST_ITEM_TV(tv_list_first(list)); expected = tv_get_string_buf_chk(tv, buf); + if (expected == NULL) { + goto theend; + } if (!pattern_match(expected, actual, false)) { error_found = true; expected_str = expected; @@ -565,6 +573,9 @@ void f_assert_fails(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) tofree = actual = xstrdup(get_vim_var_str(VV_ERRMSG)); tv = TV_LIST_ITEM_TV(tv_list_last(list)); expected = tv_get_string_buf_chk(tv, buf); + if (expected == NULL) { + goto theend; + } if (!pattern_match(expected, actual, false)) { error_found = true; expected_str = expected; |