vim-patch:7.4.1136

Problem:    Wrong argument to assert_exception() causes a crash. (reported by
            Coverity)
Solution:   Check for NULL pointer.  Add a test.

da5dcd9366
This commit is contained in:
Patrick
2016-06-30 15:13:20 +10:00
committed by prollings
parent 204f557a11
commit 8e804c911e
3 changed files with 33 additions and 2 deletions

View File

@@ -7667,7 +7667,8 @@ static void f_assert_exception(typval_T *argvars, typval_T *rettv)
ga_concat(&ga, (char_u *)"v:exception is not set"); ga_concat(&ga, (char_u *)"v:exception is not set");
assert_error(&ga); assert_error(&ga);
ga_clear(&ga); ga_clear(&ga);
} else if (strstr((char *)vimvars[VV_EXCEPTION].vv_str, error) == NULL) { } else if (error != NULL
&& strstr((char *)vimvars[VV_EXCEPTION].vv_str, error) == NULL) {
prepare_assert_error(&ga); prepare_assert_error(&ga);
fill_assert_error(&ga, &argvars[1], NULL, &argvars[0], fill_assert_error(&ga, &argvars[1], NULL, &argvars[0],
&vimvars[VV_EXCEPTION].vv_tv); &vimvars[VV_EXCEPTION].vv_tv);

View File

@@ -558,7 +558,7 @@ static int included_patches[] = {
// 1139 NA // 1139 NA
// 1138 NA // 1138 NA
1137, 1137,
// 1136, 1136,
// 1135 NA // 1135 NA
// 1134 NA // 1134 NA
// 1133 NA // 1133 NA

View File

@@ -172,4 +172,34 @@ describe('assert function:', function()
expected_errors({'command did not fail: call empty("")'}) expected_errors({'command did not fail: call empty("")'})
end) end)
end) end)
-- assert_exception({cmd}, [, {error}])
describe('assert_exception()', function()
it('should assert thrown exceptions properly', function()
source([[
try
nocommand
catch
call assert_exception('E492')
endtry
]])
expected_empty()
end)
it('should work properly when nested', function()
source([[
try
nocommand
catch
try
" illegal argument, get NULL for error
call assert_exception([])
catch
call assert_exception('E730')
endtry
endtry
]])
expected_empty()
end)
end)
end) end)