]> granicus.if.org Git - vim/commitdiff
patch 8.1.1707: Coverity warns for possibly using a NULL pointer v8.1.1707
authorBram Moolenaar <Bram@vim.org>
Wed, 17 Jul 2019 19:27:52 +0000 (21:27 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 17 Jul 2019 19:27:52 +0000 (21:27 +0200)
Problem:    Coverity warns for possibly using a NULL pointer.
Solution:   Change the logic to make sure no NULL pointer is used.

src/popupwin.c
src/testdir/test_popupwin.vim
src/version.c

index e61b793cd41646c0d4f8b9ba9f5c94a5ba94cc41..322537bf87111374c390541994b1dfd3cc4d0440 100644 (file)
@@ -587,14 +587,13 @@ apply_general_options(win_T *wp, dict_T *dict)
     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)
            {
index 8b1ea1f6f61e36451715f76dddde7e4e759cbd6f..26d1c94ae10845bb3d6b3e785543470a513cde70 100644 (file)
@@ -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()
index 573f7414236a9d7801d42289ddcc466225c51469..b1187db572e83f46aed3523fe4c26ac1948014c7 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1707,
 /**/
     1706,
 /**/