summaryrefslogtreecommitdiff
path: root/src/charset.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-05-27 22:01:40 +0200
committerBram Moolenaar <Bram@vim.org>2019-05-27 22:01:40 +0200
commit7833dab73c658e65f38553af89fd60c57a11ef49 (patch)
treea3f34d732d3f03577f6aed285de986ddb84700f1 /src/charset.c
parent60cdb3004abe683e5e8851fa6c5d67b337df4443 (diff)
downloadvim-git-7833dab73c658e65f38553af89fd60c57a11ef49.tar.gz
patch 8.1.1411: Coverity warns for divide by zerov8.1.1411
Problem: Coverity warns for divide by zero. Solution: Make sure width is larger than zero.
Diffstat (limited to 'src/charset.c')
-rw-r--r--src/charset.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/charset.c b/src/charset.c
index 171eccbfc..12e10e198 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1105,15 +1105,16 @@ win_lbr_chartabsize(
{
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 prev_width = col
? ((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);
if ((size - prev_width) % width)
- /* wrapped, add another length of 'sbr' */
+ // wrapped, add another length of 'sbr'
added += vim_strsize(p_sbr);
}
else