mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 8.1.1411: Coverity warns for divide by zero
Problem: Coverity warns for divide by zero. Solution: Make sure width is larger than zero.
This commit is contained in:
@@ -1105,15 +1105,16 @@ win_lbr_chartabsize(
|
|||||||
{
|
{
|
||||||
if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
|
if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
|
||||||
{
|
{
|
||||||
/* calculate effective window width */
|
// calculate effective window width
|
||||||
int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
|
int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
|
||||||
int prev_width = col
|
int prev_width = col
|
||||||
? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
|
? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
|
||||||
if (width == 0)
|
|
||||||
width = (colnr_T)wp->w_width;
|
if (width <= 0)
|
||||||
|
width = (colnr_T)1;
|
||||||
added += ((size - prev_width) / width) * vim_strsize(p_sbr);
|
added += ((size - prev_width) / width) * vim_strsize(p_sbr);
|
||||||
if ((size - prev_width) % width)
|
if ((size - prev_width) % width)
|
||||||
/* wrapped, add another length of 'sbr' */
|
// wrapped, add another length of 'sbr'
|
||||||
added += vim_strsize(p_sbr);
|
added += vim_strsize(p_sbr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -767,6 +767,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1411,
|
||||||
/**/
|
/**/
|
||||||
1410,
|
1410,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user