Skip to content

Commit 403d090

Browse files
committed
patch 8.1.1709: Coverity warns for possibly using a NULL pointer
Problem: Coverity warns for possibly using a NULL pointer. Solution: Make sure no NULL pointer is used.
1 parent 3fb4f47 commit 403d090

3 files changed

Lines changed: 13 additions & 10 deletions

File tree

src/popupwin.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -516,25 +516,24 @@ apply_general_options(win_T *wp, dict_T *dict)
516516
di = dict_find(dict, (char_u *)"borderhighlight", -1);
517517
if (di != NULL)
518518
{
519-
if (di->di_tv.v_type != VAR_LIST)
519+
if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL)
520520
emsg(_(e_listreq));
521521
else
522522
{
523523
list_T *list = di->di_tv.vval.v_list;
524524
listitem_T *li;
525525
int i;
526526

527-
if (list != NULL)
528-
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
529-
++i, li = li->li_next)
530-
{
531-
str = tv_get_string(&li->li_tv);
532-
if (*str != NUL)
533-
wp->w_border_highlight[i] = vim_strsave(str);
534-
}
527+
for (i = 0, li = list->lv_first; i < 4 && i < list->lv_len;
528+
++i, li = li->li_next)
529+
{
530+
str = tv_get_string(&li->li_tv);
531+
if (*str != NUL)
532+
wp->w_border_highlight[i] = vim_strsave(str);
533+
}
535534
if (list->lv_len == 1 && wp->w_border_highlight[0] != NULL)
536535
for (i = 1; i < 4; ++i)
537-
wp->w_border_highlight[i] =
536+
wp->w_border_highlight[i] =
538537
vim_strsave(wp->w_border_highlight[0]);
539538
}
540539
}

src/testdir/test_popupwin.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ func Test_popup_invalid_arguments()
634634
call popup_clear()
635635
call assert_fails('call popup_create("text", #{borderhighlight: "none"})', 'E714:')
636636
call popup_clear()
637+
call assert_fails('call popup_create("text", #{borderhighlight: test_null_list()})', 'E714:')
638+
call popup_clear()
637639
call assert_fails('call popup_create("text", #{borderchars: "none"})', 'E714:')
638640
call popup_clear()
639641

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+
1709,
780782
/**/
781783
1708,
782784
/**/

0 commit comments

Comments
 (0)