From f8f63393c12da88799cb480086922431de60ca0a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 28 May 2019 06:15:38 -0400 Subject: vim-patch:8.1.1411: fix divide by zero #10073 Problem: Coverity warns for divide by zero. Solution: Make sure width is larger than zero. https://github.com/vim/vim/commit/7833dab73c658e65f38553af89fd60c57a11ef49 --- src/nvim/charset.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index b155b3861f..9060a0de82 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1095,8 +1095,9 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he int width = (colnr_T)wp->w_width_inner - sbrlen - numberwidth; int prev_width = col ? ((colnr_T)wp->w_width_inner - (sbrlen + col)) : 0; - if (width == 0) { - width = (colnr_T)wp->w_width_inner; + + if (width <= 0) { + width = 1; } added += ((size - prev_width) / width) * vim_strsize(p_sbr); if ((size - prev_width) % width) { -- cgit