Skip to content

Commit da5dcd9

Browse files
committed
patch 7.4.1136
Problem: Wrong argument to assert_exception() causes a crash. (reported by Coverity) Solution: Check for NULL pointer. Add a test.
1 parent 3014170 commit da5dcd9

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/eval.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9278,7 +9278,8 @@ f_assert_exception(argvars, rettv)
92789278
assert_error(&ga);
92799279
ga_clear(&ga);
92809280
}
9281-
else if (strstr((char *)vimvars[VV_EXCEPTION].vv_str, error) == NULL)
9281+
else if (error != NULL
9282+
&& strstr((char *)vimvars[VV_EXCEPTION].vv_str, error) == NULL)
92829283
{
92839284
prepare_assert_error(&ga);
92849285
fill_assert_error(&ga, &argvars[1], NULL, &argvars[0],

src/testdir/test_assert.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ func Test_assert_equal()
1818
call assert_equal([1, 2, 3], l)
1919
endfunc
2020

21+
func Test_assert_exception()
22+
try
23+
nocommand
24+
catch
25+
call assert_exception('E492:')
26+
endtry
27+
28+
try
29+
nocommand
30+
catch
31+
try
32+
" illegal argument, get NULL for error
33+
call assert_exception([])
34+
catch
35+
call assert_exception('E730:')
36+
endtry
37+
endtry
38+
endfunc
39+
2140
func Test_user_is_happy()
2241
smile
2342
sleep 300m

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
1136,
744746
/**/
745747
1135,
746748
/**/

0 commit comments

Comments
 (0)