changeset 17417:aa4532c1d001 v8.1.1707

patch 8.1.1707: Coverity warns for possibly using a NULL pointer commit https://github.com/vim/vim/commit/cfdbc5adde49cbab939e8164555ed0b8d9ce000b Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 17 21:27:52 2019 +0200 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.
author Bram Moolenaar <Bram@vim.org>
date Wed, 17 Jul 2019 21:30:04 +0200
parents 2a82ba1d2dd9
children aa5e36c9f1a1
files src/popupwin.c src/testdir/test_popupwin.vim src/version.c
diffstat 3 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -587,14 +587,13 @@ apply_general_options(win_T *wp, dict_T 
     di = dict_find(dict, (char_u *)"mask", -1);
     if (di != NULL)
     {
-	int ok = TRUE;
+	int ok = FALSE;
 
-	if (di->di_tv.v_type != VAR_LIST)
-	    ok = FALSE;
-	else if (di->di_tv.vval.v_list != NULL)
+	if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
 	{
 	    listitem_T *li;
 
+	    ok = TRUE;
 	    for (li = di->di_tv.vval.v_list->lv_first; li != NULL;
 							      li = li->li_next)
 	    {
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -643,6 +643,10 @@ func Test_popup_invalid_arguments()
   call popup_clear()
   call assert_fails('call popup_create([#{text: "text", props: ["none"]}], {})', 'E715:')
   call popup_clear()
+  call assert_fails('call popup_create("text", #{mask: ["asdf"]})', 'E475:')
+  call popup_clear()
+  call assert_fails('call popup_create("text", #{mask: test_null_list()})', 'E475:')
+  call popup_clear()
 endfunc
 
 func Test_win_execute_closing_curwin()
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1707,
+/**/
     1706,
 /**/
     1705,