0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14: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:
Bram Moolenaar
2019-05-27 22:01:40 +02:00
parent 60cdb3004a
commit 7833dab73c
2 changed files with 7 additions and 4 deletions

View File

@@ -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

View File

@@ -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,
/**/ /**/