Skip to content

Commit a0ca7d0

Browse files
committed
patch 8.0.1408: crash in setqflist()
Problem: Crash in setqflist(). Solution: Check for string to be NULL. (Dominique Pelle, closes #2464)
1 parent 4af031d commit a0ca7d0

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

src/quickfix.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4930,8 +4930,9 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
49304930
qf_idx = -1;
49314931
}
49324932
}
4933-
else if ((di->di_tv.v_type == VAR_STRING)
4934-
&& (STRCMP(di->di_tv.vval.v_string, "$") == 0))
4933+
else if (di->di_tv.v_type == VAR_STRING
4934+
&& di->di_tv.vval.v_string != NULL
4935+
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
49354936
/* Get the last quickfix list number */
49364937
qf_idx = qi->qf_listcount - 1;
49374938
else
@@ -5226,7 +5227,8 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
52265227
newlist = FALSE; /* use the specified list */
52275228
}
52285229
else if (di->di_tv.v_type == VAR_STRING
5229-
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
5230+
&& di->di_tv.vval.v_string != NULL
5231+
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
52305232
{
52315233
if (qi->qf_listcount > 0)
52325234
qf_idx = qi->qf_listcount - 1;

src/testdir/test_quickfix.vim

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,11 @@ func XquickfixSetListWithAct(cchar)
14281428
call assert_fails("call g:Xsetlist(list1, 0)", 'E928:')
14291429
endfunc
14301430

1431+
func Test_setqflist_invalid_nr()
1432+
" The following command used to crash Vim
1433+
call setqflist([], ' ', {'nr' : $XXX_DOES_NOT_EXIST})
1434+
endfunc
1435+
14311436
func Test_quickfix_set_list_with_act()
14321437
call XquickfixSetListWithAct('c')
14331438
call XquickfixSetListWithAct('l')
@@ -2946,6 +2951,15 @@ func Test_getqflist()
29462951
call Xgetlist_empty_tests('l')
29472952
endfunc
29482953

2954+
func Test_getqflist_invalid_nr()
2955+
" The following commands used to crash Vim
2956+
cexpr ""
2957+
call getqflist({'nr' : $XXX_DOES_NOT_EXIST_XXX})
2958+
2959+
" Cleanup
2960+
call setqflist([], 'r')
2961+
endfunc
2962+
29492963
" Tests for the quickfix/location list changedtick
29502964
func Xqftick_tests(cchar)
29512965
call s:setup_commands(a:cchar)

src/version.c

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

772772
static int included_patches[] =
773773
{ /* Add new patch number below this line */
774+
/**/
775+
1408,
774776
/**/
775777
1407,
776778
/**/

0 commit comments

Comments
 (0)