diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-27 22:01:40 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-27 22:01:40 +0200 |
commit | 7833dab73c658e65f38553af89fd60c57a11ef49 (patch) | |
tree | a3f34d732d3f03577f6aed285de986ddb84700f1 /src/charset.c | |
parent | 60cdb3004abe683e5e8851fa6c5d67b337df4443 (diff) | |
download | vim-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.c | 9 |
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 |