To: vim_dev@googlegroups.com Subject: Patch 9.0.0404 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0404 Problem: Crash when passing invalid arguments to assert_fails(). Solution: Check for NULL string. Files: src/testing.c, src/testdir/test_assert.vim *** ../vim-9.0.0403/src/testing.c 2022-09-02 15:15:11.063569185 +0100 --- src/testing.c 2022-09-07 15:12:33.059149701 +0100 *************** *** 616,621 **** --- 616,626 ---- 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,659 **** --- 659,666 ---- 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,672 **** --- 674,681 ---- { 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; *** ../vim-9.0.0403/src/testdir/test_assert.vim 2022-09-04 21:28:15.192614789 +0100 --- src/testdir/test_assert.vim 2022-09-07 15:19:37.622137786 +0100 *************** *** 276,281 **** --- 276,296 ---- call assert_match("E1222: String or List required for argument 2", exp) try + call assert_equal(0, assert_fails('xxx', [#{one: 1}])) + catch + let exp = v:exception + endtry + call assert_match("E731: Using a Dictionary as a String", exp) + + let exp = '' + try + call assert_equal(0, assert_fails('xxx', ['E492', #{one: 1}])) + catch + let exp = v:exception + endtry + call assert_match("E731: Using a Dictionary as a String", exp) + + try call assert_equal(1, assert_fails('xxx', 'E492', '', 'burp')) catch let exp = v:exception *************** *** 289,296 **** endtry call assert_match("E1174: String required for argument 5", exp) ! call assert_equal(1, assert_fails('c0', ['', '\1'])) ! call assert_match("Expected '\\\\\\\\1' but got 'E939: Positive count required: c0': c0", v:errors[0]) call remove(v:errors, 0) endfunc --- 304,311 ---- endtry call assert_match("E1174: String required for argument 5", exp) ! call assert_equal(1, assert_fails('c0', ['', '\(.\)\1'])) ! call assert_match("Expected '\\\\\\\\(.\\\\\\\\)\\\\\\\\1' but got 'E939: Positive count required: c0': c0", v:errors[0]) call remove(v:errors, 0) endfunc *** ../vim-9.0.0403/src/version.c 2022-09-07 14:42:46.099802275 +0100 --- src/version.c 2022-09-07 15:03:12.420885620 +0100 *************** *** 705,706 **** --- 705,708 ---- { /* Add new patch number below this line */ + /**/ + 404, /**/ -- Anyone who is capable of getting themselves made President should on no account be allowed to do the job. -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///