Ken Takata wrote:

> 2017/3/22 Wed 5:58:23 UTC+9 Bram Moolenaar wrote:
> > Patch 8.0.0502
> > Problem:    Coverity complains about possible NULL pointer.
> > Solution:   Add an assert(), let's see if this works on all systems.
> > Files:      src/window.c
> > 
> > 
> > *** ../vim-8.0.0501/src/window.c    2017-03-19 20:22:31.210585166 +0100
> > --- src/window.c    2017-03-21 21:51:24.317409884 +0100
> > ***************
> > *** 3806,3811 ****
> > --- 3806,3812 ----
> >     for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tab;
> >                                                         ptp = ptp->tp_next)
> >         ;
> > +   assert(ptp != NULL);
> >     ptp->tp_next = tab->tp_next;
> >       }
> >   
> 
> If this assertion is true, can't we remove the same condition in the above
> `for` statement?
> 
>       for (ptp = first_tabpage; ptp->tp_next != tab; ptp = ptp->tp_next)

Then it would crash at "ptp = ptp->tp_next".
Well, it might not crash but do something weird on some systems.
These days many systems have the page around address zero unavailable to
force the crash, but we can't rely on it.

-- 
A bad peace is better than a good war. - Yiddish Proverb

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui