Hi, Op di 17 aug. 2021 08:31 schreef yiyuaner <[email protected]>:
> In the file misc2.c, the function coladvance2 has the following code > <https://github.com/vim/vim/blob/ccfb7c6758510e0fe5f390149ea14aee6ff4f55e/src/misc2.c#L159-%23L171> > : > > int width = curwin->w_width - win_col_off(curwin); > if (finetune > && curwin->w_p_wrap > && curwin->w_width != 0 > && wcol >= (colnr_T)width) > { > if (wcol / width > (colnr_T)csize / width) > } > > The variable width is used as a divisor but its value can be zero because: > > 1. curwin->w_width may be zero, since the code explicitly checks that > curwin->w_width > != 0 > > Since this is checked in the if statement, it can't be 0. > 1. The function win_col_off(curwin) may return zero, refer to the code > here > > <https://github.com/vim/vim/blob/ccfb7c6758510e0fe5f390149ea14aee6ff4f55e/src/move.c#L893> > . > > If it returns 0, width would be non zero, or curwin->w_width would be 0, and this is checked. So, the code path you describe can't lead to a divide by 0. If curwin->w_width is a non zero value, _and_ the call to win_col_off(curwin) returns the same value, then width can become 0. I do not have the code here to check if this is possible... Christ van Willegen -- -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CA%2BOt1OxVKUwDv6afCSsiKk%3Ds-mJN2z%3Dstd%3DxaAVQSTB-q8Fv3g%40mail.gmail.com.
