Skip to content

Commit cfdbc5a

Browse files
committed
patch 8.1.1707: Coverity warns for possibly using a NULL pointer
Problem: Coverity warns for possibly using a NULL pointer. Solution: Change the logic to make sure no NULL pointer is used.
1 parent 99a764b commit cfdbc5a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/popupwin.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,13 @@ apply_general_options(win_T *wp, dict_T *dict)
587587
di = dict_find(dict, (char_u *)"mask", -1);
588588
if (di != NULL)
589589
{
590-
int ok = TRUE;
590+
int ok = FALSE;
591591

592-
if (di->di_tv.v_type != VAR_LIST)
593-
ok = FALSE;
594-
else if (di->di_tv.vval.v_list != NULL)
592+
if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
595593
{
596594
listitem_T *li;
597595

596+
ok = TRUE;
598597
for (li = di->di_tv.vval.v_list->lv_first; li != NULL;
599598
li = li->li_next)
600599
{

src/testdir/test_popupwin.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ func Test_popup_invalid_arguments()
643643
call popup_clear()
644644
call assert_fails('call popup_create([#{text: "text", props: ["none"]}], {})', 'E715:')
645645
call popup_clear()
646+
call assert_fails('call popup_create("text", #{mask: ["asdf"]})', 'E475:')
647+
call popup_clear()
648+
call assert_fails('call popup_create("text", #{mask: test_null_list()})', 'E475:')
649+
call popup_clear()
646650
endfunc
647651

648652
func Test_win_execute_closing_curwin()

src/version.c

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

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1707,
780782
/**/
781783
1706,
782784
/**/

0 commit comments

Comments
 (0)