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.

1540d334a0

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq
2023-05-05 12:36:47 +08:00
parent 17c8e39f88
commit 5fb6b3431a
2 changed files with 28 additions and 2 deletions

View File

@@ -264,6 +264,21 @@ func Test_assert_fail_fails()
endtry
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
@@ -278,8 +293,8 @@ func Test_assert_fail_fails()
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 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