Mercurial > vim
changeset 16819:91619e48e1a7 v8.1.1411
patch 8.1.1411: Coverity warns for divide by zero
commit https://github.com/vim/vim/commit/7833dab73c658e65f38553af89fd60c57a11ef49
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 27 22:01:40 2019 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 27 May 2019 22:15:05 +0200 |
parents | 14c0e527b63c |
children | 5e02daf3e49c |
files | src/charset.c src/version.c |
diffstat | 2 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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