diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-09-07 15:20:26 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-07 15:20:26 +0100 |
commit | 1540d334a04d874c2aa9d26b82dbbcd4bc5a78de (patch) | |
tree | 6acc5457c4385a4357b5a1640e501d2ce929eae6 /src/testing.c | |
parent | fd7e60a33ddd83a82da4eb6267f1c12fa926f32b (diff) | |
download | vim-git-1540d334a04d874c2aa9d26b82dbbcd4bc5a78de.tar.gz |
patch 9.0.0404: crash when passing invalid arguments to assert_fails()v9.0.0404
Problem: Crash when passing invalid arguments to assert_fails().
Solution: Check for NULL string.
Diffstat (limited to 'src/testing.c')
-rw-r--r-- | src/testing.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/testing.c b/src/testing.c index 8c682cf6b..fb5c9ab4c 100644 --- a/src/testing.c +++ b/src/testing.c @@ -616,6 +616,11 @@ f_assert_fails(typval_T *argvars, typval_T *rettv) in_assert_fails = TRUE; 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); @@ -654,6 +659,8 @@ f_assert_fails(typval_T *argvars, typval_T *rettv) CHECK_LIST_MATERIALIZE(list); tv = &list->lv_first->li_tv; expected = tv_get_string_buf_chk(tv, buf); + if (expected == NULL) + goto theend; if (!pattern_match(expected, actual, FALSE)) { error_found = TRUE; @@ -667,6 +674,8 @@ f_assert_fails(typval_T *argvars, typval_T *rettv) { tv = &list->lv_u.mat.lv_last->li_tv; expected = tv_get_string_buf_chk(tv, buf); + if (expected == NULL) + goto theend; if (!pattern_match(expected, actual, FALSE)) { error_found = TRUE; |